yhluo 1 mese fa
parent
commit
1ac9bb3b03
1 ha cambiato i file con 60 aggiunte e 88 eliminazioni
  1. 60 88
      UAS_MES_HYSX/FunctionCode/Make/Make_ParseLog.cs

+ 60 - 88
UAS_MES_HYSX/FunctionCode/Make/Make_ParseLog.cs

@@ -51,7 +51,7 @@ namespace UAS_MES_NEW.Make
         {
             dh = SystemInf.dh;
             Choose.Enabled = false;
-            fileList.Add("C:\\Users\\MI\\Desktop");
+            fileList.Add("E:\\AOIMes\\Mes");
             fileList.Add("C:\\Users\\MI\\Desktop");
             fileList.Add("C:\\Users\\MI\\Desktop");
 
@@ -98,31 +98,24 @@ namespace UAS_MES_NEW.Make
         {
             if (Device.SelectedIndex == -1) return;
 
+            if(ChangeWoTimer.Enabled)   ChangeWoTimer.Stop();
             switch (Device.SelectedIndex)
             {
                 case 0:
                     currFileType = "Txt";
                     equiType = "AOI";
-                    //ChangeWoTimer.Start();
+                    /*ChangeWoTimer.Start();
+                    ChangeWoFunc(null, null);*/
                     break;
                 case 1:
                     currFileType = "jpg";
                     equiType = "Xray";
-                    //ChangeWoTimer.Stop();
                     break;
                 case 2:
                     currFileType = "jpg";
                     equiType = "CCD";
-                    //ChangeWoTimer.Stop();
                     break;
             }
-            if (string.IsNullOrEmpty(ma_code.Text))
-            {
-                Device.SelectedIndex = -1;
-                txtPath.Text = "";
-                MessageBox.Show(this.ParentForm, "请选择工单", "提示");
-                return;
-            }
 
             txtPath.Text = fileList[Device.SelectedIndex];
             txtPath.Focus();
@@ -153,14 +146,6 @@ namespace UAS_MES_NEW.Make
 
         private void allParse_Click(object sender, EventArgs e)
         {
-            if (Device.SelectedIndex == 0)
-            {
-                if (string.IsNullOrEmpty(ma_code.Text))
-                {
-                    MessageBox.Show(this.ParentForm, "请选择工单", "提示");
-                    return;
-                }
-            }
             if (Device.SelectedIndex == -1)
             {
                 Device.Focus();
@@ -178,30 +163,33 @@ namespace UAS_MES_NEW.Make
             string[] txtFiles;
             if (equiType == "Xray")
             {
+                if (string.IsNullOrEmpty(ma_code.Text))
+                {
+                    MessageBox.Show(this.ParentForm, "请选择工单", "提示");
+                    return;
+                }
+
                 txtFiles = Directory.GetDirectories(txtPath.Text);
+                if (txtFiles.Length == 0)
+                {
+                    LogMessage(0, $"当前路径{txtPath.Text},没有{equiType}设备输出的文件夹");
+                    return;
+                }
             }
             else
             {
                 txtFiles = Directory.GetFiles(txtPath.Text, $"*.{currFileType}");
-            }
-            if (txtFiles.Length == 0)
-            {
-                LogMessage(0, $"当前{txtPath.Text},没有{equiType}设备输出的{currFileType.ToLower()}文件");
-                return;
+                if (txtFiles.Length == 0)
+                {
+                    LogMessage(0, $"当前{txtPath.Text},没有{equiType}设备输出的{currFileType.ToLower()}文件");
+                    return;
+                }
             }
             RefreshFileList();
         }
 
         private void onWatch_Click(object sender, EventArgs e)
         {
-            if (Device.SelectedIndex == 0)
-            {
-                if (string.IsNullOrEmpty(ma_code.Text))
-                {
-                    MessageBox.Show(this.ParentForm, "请选择工单", "提示");
-                    return;
-                }
-            }
             if (Device.SelectedIndex == -1)
             {
                 Device.Focus();
@@ -216,6 +204,14 @@ namespace UAS_MES_NEW.Make
                 MessageBox.Show(this.ParentForm, "请选择解析路径", "提示");
                 return;
             }
+            if (equiType == "Xray")
+            {
+                if (string.IsNullOrEmpty(ma_code.Text))
+                {
+                    MessageBox.Show(this.ParentForm, "请选择工单", "提示");
+                    return;
+                }
+            }
             try
             {
                 watcher.Path = txtPath.Text;
@@ -436,84 +432,60 @@ namespace UAS_MES_NEW.Make
                 List<string> param = new List<string>() { };
                 foreach (var item in logs)
                 {
-                    //string sqlStr = $@"select ma_code,nvl(mcd_okqty,0) mcd_okqty,ma_prodcode,pr_detail,ma_qty - nvl(mcd_okqty, 0) remain_qty 
-                    //                    from make left join makecraftdetail on mcd_maid=ma_id left join product on pr_code = ma_prodcode 
-                    //                    where ma_code='{ma_code.Text}' and mcd_stepcode='" + User.CurrentStepCode + "'";
-                    //dt = (DataTable)dh.ExecuteSql(sqlStr, "select");
-                    //BaseUtil.SetFormValue(Controls, dt);
-
-                    string outMsg = "";
-                    param.Add(ma_code.Text);
-                    param.Add(item.SN); 
-                    param.Add(User.UserSourceCode);
-                    param.Add(item.Result.ToUpper());
-                    param.Add(item.TestTime);
-                    param.Add(item.Side);
-                    param.Add(equiType);
-                    details.Clear();
-                    foreach (LogItem LI in item.LogItemList)
-                    {
-                        details.Append($"{LI.Location}/{LI.ReelNo}/{LI.FirstType}/{LI.SceondType}/{LI.Name};");
-                    }
-                    param.Add(details.ToString());
-                    param.Add(outMsg);
-                    string[] paramList = param.ToArray();
-                    dh.CallProcedure("cs_insert_testrejects", ref paramList);
-                    if(paramList[8].Substring(0, 2) == "OK")
-                    {
-                        LogMessage(1, $"文件: {item.SN} 采集成功, 测试结果为{item.Result},共{item.LogItemList.Count}条信息");
-                    }
-                    else
-                    {
-                        LogMessage(1, paramList[8]);
-                    }
-                    param.Clear();
-
-                    if (logs.IndexOf(item) == logs.Count - 1)
-                    {
-                        LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, ma_code.Text, User.UserLineCode, User.UserSourceCode, "日志解析", "日志解析过站成功", item.SN, "");
-                        return true;
-                    }
-                   /* if (LogicHandler.CheckStepSNAndMacode(ma_code.Text, User.UserSourceCode, item.SN, User.UserCode, false, out omakeCode, out oMsid, out oErrorMessage))
+                    if (LogicHandler.CheckStepSNAndMacode(ma_code.Text, User.UserSourceCode, item.SN, User.UserCode, out omakeCode, out oMsid, out oErrorMessage))
                     {
-                        if (LogicHandler.SetStepResult(omakeCode, User.UserSourceCode, item.SN, "设备日志解析", "OK", User.UserCode, false, out oErrorMessage))
+                        if (LogicHandler.SetStepResult(omakeCode, User.UserSourceCode, item.SN, "日志解析", "解析过站成功", User.UserCode, out oErrorMessage))
                         {
-                            string sqlStr = $@"select ma_code,nvl(mcd_okqty,0) mcd_okqty,ma_prodcode,pr_detail,ma_qty - nvl(mcd_okqty, 0) remain_qty 
-                                        from make left join makecraftdetail on mcd_maid=ma_id left join product on pr_code = ma_prodcode 
-                                        where ma_code='" + omakeCode + "' and mcd_stepcode='" + User.CurrentStepCode + "'";
-                            dt = (DataTable)dh.ExecuteSql(sqlStr, "select");
-                            BaseUtil.SetFormValue(Controls, dt);
-                            //记录操作日志
-                            LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, ma_code.Text, User.UserLineCode, User.UserSourceCode, "日志解析", "日志解析成功", item.SN, "");
-
                             string outMsg = "";
-                            param.Add(item.SN);
                             param.Add(omakeCode);
+                            param.Add(item.SN);
                             param.Add(User.UserSourceCode);
-                            param.Add(item.Result);
+                            param.Add(item.Result.ToUpper());
+                            param.Add(item.TestTime);
+                            param.Add(item.Side);
+                            param.Add(equiType);
+                            details.Clear();
+                            foreach (LogItem LI in item.LogItemList)
+                            {
+                                details.Append($"{LI.Location}/{LI.ReelNo}/{LI.FirstType}/{LI.SceondType}/{LI.Name};");
+                            }
+                            param.Add(details.ToString());
                             param.Add(outMsg);
-
                             string[] paramList = param.ToArray();
-                            dh.CallProcedure("cs_insert_testdetail", ref paramList);
-                            LogMessage($"文件: {PathName},共{fileNum}条记录SN: {item.SN}解析已过站");
+                            dh.CallProcedure("cs_insert_testrejects", ref paramList);
+                            if (paramList[8].Substring(0, 2) == "OK")
+                            {
+                                LogMessage(1, $"文件: {item.SN} 采集成功, 测试结果为{item.Result},共{item.LogItemList.Count}条信息");
+                            }
+                            else
+                            {
+                                LogMessage(1, paramList[8]);
+                            }
                             param.Clear();
 
                             if (logs.IndexOf(item) == logs.Count - 1)
                             {
+                                //string sqlStr = $@"select ma_code,nvl(mcd_okqty,0) mcd_okqty,ma_prodcode,pr_detail,ma_qty - nvl(mcd_okqty, 0) remain_qty 
+                                //                    from make left join makecraftdetail on mcd_maid=ma_id left join product on pr_code = ma_prodcode 
+                                //                    where ma_code='{omakeCode}' and mcd_stepcode='" + User.CurrentStepCode + "'";
+                                //dt = (DataTable)dh.ExecuteSql(sqlStr, "select");
+                                //BaseUtil.SetFormValue(Controls, dt);
+
+                                LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, omakeCode, User.UserLineCode, User.UserSourceCode, "日志解析", "日志解析过站成功", item.SN, "");
                                 return true;
                             }
                         }
                         else
                         {
-                            LogMessage($"处理过站NG:{oErrorMessage}");
+                            LogMessage(0, $"处理过站NG:{oErrorMessage}");
                             break;
                         }
                     }
                     else
                     {
-                        LogMessage($"过站核对NG:{oErrorMessage}");
+                        LogMessage(0, $"过站核对NG:{oErrorMessage}");
                         break;
-                    }*/
+                    }
                 }
                 return false;
             }