Jelajahi Sumber

spi的自动识别工单和aoi过站工单不匹配

yhluo 5 bulan lalu
induk
melakukan
bcb3ea1eb8
1 mengubah file dengan 77 tambahan dan 15 penghapusan
  1. 77 15
      UAS_MES_BG/FunctionCode/Make/Make_ParseLog.cs

+ 77 - 15
UAS_MES_BG/FunctionCode/Make/Make_ParseLog.cs

@@ -51,7 +51,7 @@ namespace UAS_MES_NEW.Make
         string SN, omakeCode, oMsid, oErrorMessage = "";
         string SN, omakeCode, oMsid, oErrorMessage = "";
         List<string> fileList = new List<string>();
         List<string> fileList = new List<string>();
 
 
-        Timer formsTimer;
+        Timer formsTimer,SPITimer;
         string outXmlFilePath;
         string outXmlFilePath;
 
 
         private void Make_ParseLog_Load(object sender, EventArgs e)
         private void Make_ParseLog_Load(object sender, EventArgs e)
@@ -68,6 +68,11 @@ namespace UAS_MES_NEW.Make
             formsTimer = new Timer();
             formsTimer = new Timer();
             formsTimer.Interval = 10000;
             formsTimer.Interval = 10000;
             formsTimer.Tick += timer1_Tick;
             formsTimer.Tick += timer1_Tick;
+
+            SPITimer = new Timer();
+            SPITimer.Interval = 30000;
+            SPITimer.Tick += SPITimer_Tick;
+
             //outXmlFilePath = "C:\\Users\\MI\\Desktop\\贴片机\\outLogs";
             //outXmlFilePath = "C:\\Users\\MI\\Desktop\\贴片机\\outLogs";
             outXmlFilePath = "D:\\JANETSSR";
             outXmlFilePath = "D:\\JANETSSR";
 
 
@@ -115,26 +120,34 @@ namespace UAS_MES_NEW.Make
                 case 0:
                 case 0:
                     currFileType = "txt";
                     currFileType = "txt";
                     equiType = "SPI";
                     equiType = "SPI";
+
+                    SPITimer_Tick(null, null);
+                    SPITimer.Start();
                     break;
                     break;
                 case 1:
                 case 1:
                     currFileType = "csv";
                     currFileType = "csv";
                     equiType = "SPI";
                     equiType = "SPI";
+                    SPITimer.Stop();
                     break;
                     break;
                 case 2:
                 case 2:
                     currFileType = "txt";
                     currFileType = "txt";
                     equiType = "AOI";
                     equiType = "AOI";
+                    SPITimer.Stop();
                     break;
                     break;
                 case 3:
                 case 3:
                     currFileType = "csv";
                     currFileType = "csv";
                     equiType = "印刷机";
                     equiType = "印刷机";
+                    SPITimer.Stop();
                     break;
                     break;
                 case 4:
                 case 4:
                     currFileType = "xml";
                     currFileType = "xml";
                     equiType = "贴片机";
                     equiType = "贴片机";
+                    SPITimer.Stop();
                     break;
                     break;
                 case 5:
                 case 5:
                     currFileType = "xml";
                     currFileType = "xml";
                     equiType = "贴片机";
                     equiType = "贴片机";
+                    SPITimer.Stop();
                     break;
                     break;
             }
             }
 
 
@@ -147,13 +160,13 @@ namespace UAS_MES_NEW.Make
                 txtPath.SelectAll();
                 txtPath.SelectAll();
                 return;
                 return;
             }
             }
-            if (string.IsNullOrEmpty(ma_code.Text))
-            {
-                Device.SelectedIndex = -1;
-                txtPath.Text = "";
-                MessageBox.Show(this.ParentForm, "请选择工单", "提示");
-                return;
-            }
+            //if (string.IsNullOrEmpty(ma_code.Text))
+            //{
+            //    Device.SelectedIndex = -1;
+            //    txtPath.Text = "";
+            //    MessageBox.Show(this.ParentForm, "请选择工单", "提示");
+            //    return;
+            //}
 
 
             txtPath.Text = fileList[Device.SelectedIndex];
             txtPath.Text = fileList[Device.SelectedIndex];
             txtPath.Focus();
             txtPath.Focus();
@@ -362,8 +375,43 @@ namespace UAS_MES_NEW.Make
             }
             }
         }
         }
 
 
+        private void SPITimer_Tick(object sender, EventArgs e)
+        {
+            try
+            {
+                sql.Clear();
+                sql.Append($"SELECT dl_macode FROM deviceline WHERE dl_type = 'SMT' AND dl_linecode = '{User.UserLineCode}'");
+                dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
+                if (dt.Rows.Count > 0 && !String.IsNullOrEmpty(dt.Rows[0]["dl_macode"].ToString()))
+                {
+                    ma_code.Text = dt.Rows[0]["dl_macode"].ToString().Trim();
+                    return;
+                }
+
+                sql.Clear();
+                sql.Append($"SELECT dl_macode FROM deviceline WHERE dl_linecode = '{User.UserLineCode}' AND dl_type IS NULL");
+                dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
+                if (dt.Rows.Count > 0 && !String.IsNullOrEmpty(dt.Rows[0]["dl_macode"].ToString()))
+                {
+                    ma_code.Text = dt.Rows[0]["dl_macode"].ToString().Trim();
+                }
+            }
+            catch (Exception ex)
+            {
+                LogMessage($"SPI自动识别生产工单Error: {ex.Message}");
+            }
+        }
+
         private void OnFileCreated(object sender, FileSystemEventArgs e)
         private void OnFileCreated(object sender, FileSystemEventArgs e)
         {
         {
+            if (Device.SelectedIndex == 0 && string.IsNullOrEmpty(ma_code.Text))
+            {
+                Device.SelectedIndex = -1;
+                txtPath.Text = "";
+                MessageBox.Show(this.ParentForm, "请选择工单", "提示");
+                return;
+            }
+
             RefreshFileList();
             RefreshFileList();
         }
         }
 
 
@@ -855,35 +903,49 @@ namespace UAS_MES_NEW.Make
                 {
                 {
                     if (string.IsNullOrEmpty(item)) continue;
                     if (string.IsNullOrEmpty(item)) continue;
                     string[] currItem = item.Split(',');
                     string[] currItem = item.Split(',');
-                    string res = "",wo = "",detail = "";
+                    string res = "",wo = "",detail = "",line = "";
                     if(equiType == "SPI")
                     if(equiType == "SPI")
                     {
                     {
                         res = currItem[1];
                         res = currItem[1];
                         wo = ma_code.Text;
                         wo = ma_code.Text;
                         detail = currItem[1];
                         detail = currItem[1];
+                        line = User.UserLineCode;
                     }
                     }
                     else if (equiType == "AOI")
                     else if (equiType == "AOI")
                     {
                     {
-                        res = currItem[1];
-                        detail = currItem[1];
-                        if (currItem.Length > 3)
+                        if (currItem.Length > 2)
                         {
                         {
+                            res = currItem[3];
+                            detail = currItem[3];
+
                             sql.Clear();
                             sql.Clear();
                             sql.Append($"SELECT a.li_code,b.dl_macode,c.sc_name FROM line_ipaoi a,deviceline b,source c WHERE a.ipaddress = '{currItem[2]}' AND a.li_code = b.dl_linecode AND a.li_code = c.sc_linecode AND c.sc_wccode = 'SMT' AND instr(c.sc_name, 'AOI') > 0 AND b.dl_type = 'SMT'");
                             sql.Append($"SELECT a.li_code,b.dl_macode,c.sc_name FROM line_ipaoi a,deviceline b,source c WHERE a.ipaddress = '{currItem[2]}' AND a.li_code = b.dl_linecode AND a.li_code = c.sc_linecode AND c.sc_wccode = 'SMT' AND instr(c.sc_name, 'AOI') > 0 AND b.dl_type = 'SMT'");
                             dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
                             dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
                             if (dt.Rows.Count > 0 && !String.IsNullOrEmpty(dt.Rows[0]["dl_macode"].ToString()))
                             if (dt.Rows.Count > 0 && !String.IsNullOrEmpty(dt.Rows[0]["dl_macode"].ToString()))
                             {
                             {
                                 wo = dt.Rows[0]["dl_macode"].ToString();
                                 wo = dt.Rows[0]["dl_macode"].ToString();
+                                line = dt.Rows[0]["li_code"].ToString();
+                            }
+                        }else if (currItem.Length == 2)
+                        {
+                            res = currItem[1];
+                            detail = currItem[1];
+
+                            sql.Clear();
+                            sql.Append($"SELECT a.ms_linecode, a.ms_makecode FROM makeserial a WHERE a.ms_sncode = '{currItem[0]}'");
+                            dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
+                            if (dt.Rows.Count > 0 && !String.IsNullOrEmpty(dt.Rows[0]["ms_linecode"].ToString()))
+                            {
+                                wo = dt.Rows[0]["ms_makecode"].ToString();
+                                line = dt.Rows[0]["ms_linecode"].ToString();
                             }
                             }
-                            res = currItem[3];
-                            detail = currItem[3];
                         }
                         }
                     }
                     }
                     Log itemLog = new Log()
                     Log itemLog = new Log()
                     {
                     {
                         SN = currItem[0],
                         SN = currItem[0],
                         Work_order = wo,
                         Work_order = wo,
-                        Line = User.UserLineCode,
+                        Line = line,
                         Source = User.UserSourceCode,
                         Source = User.UserSourceCode,
                         Result = res,
                         Result = res,
                         Details = detail
                         Details = detail