Browse Source

调整CCD对接

yhluo 3 weeks ago
parent
commit
730ab94418
1 changed files with 58 additions and 23 deletions
  1. 58 23
      UAS_MES_HYSX/FunctionCode/Make/Make_ParseLog.cs

+ 58 - 23
UAS_MES_HYSX/FunctionCode/Make/Make_ParseLog.cs

@@ -53,7 +53,7 @@ namespace UAS_MES_NEW.Make
             Choose.Enabled = false;
             fileList.Add("E:\\AOIMes\\Mes");
             fileList.Add("E:\\UAS");
-            fileList.Add("C:\\Users\\MI\\Desktop");
+            fileList.Add("");
 
             ChangeWoTimer = new Timer();
             ChangeWoTimer.Interval = 30000;
@@ -285,10 +285,7 @@ namespace UAS_MES_NEW.Make
                 {
                     if (equiType == "Xray")
                     {
-                        if (Path.GetFileName(file).Contains("Log_"))
-                        {
-                            continue;
-                        }
+                        if (Path.GetFileName(file).Contains("Log_")) continue;
 
                         if (!Directory.Exists(file))
                         {
@@ -305,6 +302,14 @@ namespace UAS_MES_NEW.Make
                             }
                             continue;
                         }
+                    }else if (equiType == "CCD")
+                    {
+                        outFileMsg = CheckFileAccess(file);
+                        if (outFileMsg != "OK")
+                        {
+                            //LogMessage(0, outFileMsg);
+                            //continue;
+                        }
                     }
                     else
                     {
@@ -313,13 +318,6 @@ namespace UAS_MES_NEW.Make
                             LogMessage(0, $"文件不存在: {file}");
                         }
 
-                        //outFileMsg = CheckFileAccess(file);
-                        //if (outFileMsg != "OK")
-                        //{
-                        //    //LogMessage(0, outFileMsg);
-                        //    continue;
-                        //}
-
                         if (File.ReadAllText(file).Length == 0)
                         {
                             continue;
@@ -407,32 +405,69 @@ namespace UAS_MES_NEW.Make
                     }
                     else if(equiType == "CCD")
                     {
-                        if (txtFiles.Length != 2) break;
-
                         foreach (var fileItem in txtFiles)
                         {
                             string imageName = Path.GetFileName(fileItem);
-                            SN = imageName.Split('_')[0].ToString();
+                            string iName = imageName.Split('_')[0];
+                            if (iName.Length > 14)
+                            {
+                                SN = iName.Length > 14 ? iName.Substring(3) : "";
+                            }
 
                             if (imageName.ToUpper().Contains("NG"))
                             {
-                                if (UploadImageToFtp(fileItem, SN))
+                                if (txtFiles.Length != 3)
                                 {
-                                    dh.ExecuteSql($@"INSERT INTO steptestmain (sm_id, sm_sn,sm_makecode,sm_stepcode,sm_indate,sm_machinecode,sm_result) 
-                                            VALUES ( steptestmain_seq.NEXTVAL,'{SN}','{ma_code.Text}','{User.UserSourceCode}', sysdate,'CCD', 'http://192.168.1.5:8088/ftp/ccd/{SN}/{Path.GetFileName(fileItem)}' )", "insert");
+                                    SN = "";
+                                    return;
+                                }
+                            }
+                            else if(imageName.ToUpper().Contains("OK"))
+                            {
+                                if (txtFiles.Length != 2)
+                                {
+                                    SN = "";
+                                    return;
                                 }
                             }
-                            string parentPath = Path.GetDirectoryName(file);
-                            string changeName = Path.Combine(parentPath, SN);
+                        }
+
+                        string parentPath = Path.GetDirectoryName(file);
+                        string newFolderPath = Path.Combine(parentPath, "Logs");
+                        if (!Directory.Exists(newFolderPath))
+                        {
+                            Directory.CreateDirectory(newFolderPath);
+                        }
+                        string changeName = Path.Combine(newFolderPath, SN);
+                        if (!Directory.Exists(changeName))
+                        {
+                            Directory.CreateDirectory(changeName);
+                        }
+
+                        string result = Path.GetFileName(file).Split('_')[0];
 
-                            if (!Directory.Exists(changeName))
+                        if (result.ToUpper().Contains("NG"))
+                        {
+                            if (UploadImageToFtp(file, SN))
                             {
-                                Directory.CreateDirectory(changeName);
+                                dh.ExecuteSql($@"INSERT INTO steptestmain (sm_id, sm_sn,sm_makecode,sm_stepcode,sm_indate,sm_machinecode,sm_result) 
+                                        VALUES (steptestmain_seq.NEXTVAL,'{SN}','{ma_code.Text}','{User.UserSourceCode}', sysdate,'CCD', 'http://192.168.1.5:8088/ftp/ccd/{SN}/{Path.GetFileName(file)}' )", "insert");
                             }
-                            File.Move(file, changeName);
                         }
+                        string targetFile = Path.Combine(changeName, Path.GetFileName(file));
+
+                        if (File.Exists(targetFile))
+                        {
+                            File.Delete(targetFile);
+                        }
+                        File.Move(file, targetFile);
                     }
                 }
+                if (equiType == "CCD")
+                {
+
+                    LogMessage(1, $"序列号: {SN} 图片已处理");
+                }
             }
             catch (Exception ex)
             {