WIN-GH9CEESPLTB\Administrator преди 4 месеца
родител
ревизия
a9cfb90530
променени са 1 файла, в които са добавени 53 реда и са изтрити 2 реда
  1. 53 2
      MainForm/FaForm/Form_Home.cs

+ 53 - 2
MainForm/FaForm/Form_Home.cs

@@ -1205,6 +1205,57 @@ namespace MainForm
                 proDate, supplierCode, sn, pass, vehicleSn, vehicleSlot, MachineId, StationId, PartBarcode);
         }
 
+        /// <summary>
+        /// 图片存入数据库
+        /// </summary>
+        /// <param name="stPLC_MesData"></param>
+        /// <param name="stationCode"></param>
+        /// <param name="stationName"></param>
+        private void SaveDBbyFileInfo(OP40_MesData_t stPLC_MesData, string stationCode, string stationName) {
+            string path = GlobalContext.FilePath;
+            string leftPath = path + "\\Left";
+            string rightPath = path + "\\Right";
+            string sql = "";
+
+            // 获取所有图片文件
+            List<string> imageFiles_L = GetAllImageFiles(leftPath);
+            List<string> imageFiles_R = GetAllImageFiles(rightPath);
+            foreach (string imageFile in imageFiles_L) {
+
+                sql = "";
+            }
+        }
+
+        /// <summary>
+        /// 获取路径下的所有图片
+        /// </summary>
+        /// <param name="directoryPath"></param>
+        /// <returns></returns>
+        private List<string> GetAllImageFiles(string directoryPath)
+        {
+            var imageExtensions = new HashSet<string>(StringComparer.OrdinalIgnoreCase) { ".jpg", ".jpeg", ".png", ".bmp", ".gif", ".tiff" };
+            var imageFiles = new List<string>();
+
+            try
+            {
+                // 遍历目录及子目录中的所有文件
+                foreach (string file in Directory.EnumerateFiles(directoryPath, "*.*", SearchOption.AllDirectories))
+                {
+                    // 获取文件扩展名并检查是否为图片格式
+                    string extension = Path.GetExtension(file);
+                    if (imageExtensions.Contains(extension))
+                    {
+                        imageFiles.Add(file);
+                    }
+                }
+            }
+            catch (Exception ex)
+            {
+                OnMessage(LogType.Error, $"图片查询发生错误: {ex.Message}");
+            }
+            return imageFiles;
+        }
+
         /// <summary>
         /// 添加出站数据(提交到MES+本地保存到数据库)
         /// </summary>
@@ -2123,7 +2174,7 @@ namespace MainForm
                 //这个地方之后PLC可能会返回SN码,到时用返回的和数据库中的比较下对错,结果faalse怎么办现在不知道
                 //sn = strProductBarcode;
                 if (sn!= strProductBarcode) {
-                    AddMessage(LogType.Info, $"S2进站产品码错误!与S1进展产品码不匹配,S2产品码:{sn};S1产品码:{strProductBarcode}");
+                    AddMessage(LogType.Info, $"进站产品码错误!与载具绑定的产品码不匹配,进站产品码:{sn};载具绑定产品码:{strProductBarcode}");
                 }
                 AddMessage(LogType.Info, $"载具码:{strCarrierBarcode};产品码:{sn}");
 
@@ -3103,7 +3154,7 @@ namespace MainForm
                 //这个地方之后PLC可能会返回SN码,到时用返回的和数据库中的比较下对错,结果faalse怎么办现在不知道
                 if (sn != strProductBarcode)
                 {
-                    AddMessage(LogType.Info, $"S5进站产品码错误!与S1进站产品码不匹配,S5产品码:{sn};S1产品码:{strProductBarcode}");
+                    AddMessage(LogType.Info, $"进站产品码错误!与载具绑定的产品码不匹配,进站产品码:{sn};载具绑定产品码:{strProductBarcode}");
                 }
                 //sn = strProductBarcode;
                 AddMessage(LogType.Info, $"载具码:{strCarrierBarcode};产品码:{sn}");