Ver código fonte

Merge branch 'LCD组装' of http://49.235.130.76/XXF_1122/DaisyNPILine into LCD组装

KWD 5 meses atrás
pai
commit
c440c104ca

+ 40 - 4
TeamAAS-VM/Core/Management.cs

@@ -3266,17 +3266,16 @@ namespace TeamAAS_VP.Core
                                                     {
                                                         DateTime dt = DateTime.Now;
                                                         string filename = $"{ProductMainSN[i]}_{dt.ToString("yyyyMMddHHmmss")}";
-                                                        //string csvfilename = $"{i}_{stationConfig.DeviceName}_{dt.ToString("yyyy-MM-dd")}";
+                                                        string csvfilename = $"{i}_{stationConfig.DeviceName}_{dt.ToString("yyyy-MM-dd")}";
                                                         var device = _configService.GetDeviceInfo(i);
                                                         var systemConfig = _configService.GetSystemConfiguration();
                                                         var pressureSensorConfig = systemConfig.PressureSensorConfig.FirstOrDefault();
-                                                        (bool isSuc, string resp) = await _mesService.SendFtpFileAsync(ProductMainSN[i], filename);
+                                                        (bool isSuc, string resp) = await _mesService.SendFtpFileAsync(ProductMainSN[i], filename, device);
                                                         if (isSuc)
                                                         {
                                                             LogHelper.WriteLogMes($"上传数据成功");
                                                             SendTaskMessage($"上传数据成功", MessageLevel.Debug);
                                                             string filePath = $"D:\\image\\Recored\\{dt.ToString("yyyy-MM")}\\{dt.ToString("MM-dd")}\\{currentProduct.Name}\\{ProductMainSN[i]}";
-                                                            string source_csv2 = $"{stationConfig.SaveCsvPath}\\{dt.ToString("yyyy-MM")}\\{i}_{stationConfig.DeviceName}_{dt.ToString("yyyy-MM-dd")}";
                                                             if (!Directory.Exists(filePath))
                                                             {
                                                                 Directory.CreateDirectory(filePath);
@@ -3322,7 +3321,7 @@ namespace TeamAAS_VP.Core
                                                             if (isAfter20 && isNewDay && !_hasCompressedToday)
                                                             {
                                                                 // 执行压缩
-                                                                CompressionImage(source_csv2, filename, device.Station, device.FixtureId);
+                                                                CompressionSingleCsv(source_csv, csvfilename, device.Station, device.FixtureId);
                                                                 _lastCompressDate = dt;
                                                                 _hasCompressedToday = true;
                                                                 LogHelper.WriteLogMes("csv上传数据成功");
@@ -3887,6 +3886,7 @@ namespace TeamAAS_VP.Core
                     }
 
                     ZipFile.CreateFromDirectory(sourcePath, zipPath);
+
                 });
             }
             catch (Exception ex)
@@ -3894,7 +3894,43 @@ namespace TeamAAS_VP.Core
                 LogHelper.WriteLogError($"压缩文件时出错", ex);
             }
         }
+        public async void CompressionSingleCsv(string csvFilePath, string zipname, string station, string fixid)
+        {
+            string zipPath = "";
+            try
+            {
+                SendTaskMessage("开始压缩CSV文件", MessageLevel.Info);
+                await Task.Run(() =>
+                {
+                    if (!File.Exists(csvFilePath))
+                    {
+                        LogHelper.WriteLogMes($"CSV文件不存在,不压缩:{csvFilePath}");
+                        return;
+                    }
 
+                    zipPath = $"Z:\\{station}\\{fixid}\\{DateTime.Now.ToString("yyyyMMdd")}\\{zipname}.zip";
+                    string path = $"Z:\\{station}\\{fixid}\\{DateTime.Now.ToString("yyyyMMdd")}";
+
+                    if (!Directory.Exists(path))
+                    {
+                        Directory.CreateDirectory(path);
+                    }
+
+                    using (FileStream fs = new FileStream(zipPath, FileMode.Create))
+                    {
+                        using (ZipArchive archive = new ZipArchive(fs, ZipArchiveMode.Create))
+                        {
+                            archive.CreateEntryFromFile(csvFilePath, Path.GetFileName(csvFilePath));
+                        }
+                    }
+                });
+                SendTaskMessage("CSV文件压缩完成", MessageLevel.Debug);
+            }
+            catch (Exception ex)
+            {
+                LogHelper.WriteLogError("压缩CSV文件失败", ex);
+            }
+        }
         #endregion
         #endregion
     }

+ 2 - 1
TeamAAS-VM/Interfaces/IMesService.cs

@@ -2,6 +2,7 @@ using System;
 using System.Collections.Generic;
 using System.Threading;
 using System.Threading.Tasks;
+using TeamAAS_VP.Models;
 
 namespace TeamAAS_VP.Interfaces
 {
@@ -128,6 +129,6 @@ namespace TeamAAS_VP.Interfaces
         /// <param name="name"></param>
         /// <param name="cancellationToken"></param>
         /// <returns></returns>
-        Task<(bool IsSuccess, string Response)> SendFtpFileAsync(string sn, string name, CancellationToken cancellationToken = default);
+        Task<(bool IsSuccess, string Response)> SendFtpFileAsync(string sn, string name,DeviceInfo device, CancellationToken cancellationToken = default);
     }
 }

+ 9 - 0
TeamAAS-VM/Resources/Languages/Lang.en.resx

@@ -3174,4 +3174,13 @@
   <data name="SettingView_Language_Vietnamese" xml:space="preserve">
     <value>Vietnamese</value>
   </data>
+  <data name="生产" xml:space="preserve">
+    <value>production</value>
+  </data>
+  <data name="调机" xml:space="preserve">
+    <value>machine adjustment</value>
+  </data>
+  <data name="流线" xml:space="preserve">
+    <value>streamline</value>
+  </data>
 </root>

+ 9 - 0
TeamAAS-VM/Resources/Languages/Lang.ja-JP.resx

@@ -3174,4 +3174,13 @@
   <data name="SettingView_Language_Vietnamese" xml:space="preserve">
     <value>ベトナム語</value>
   </data>
+  <data name="生产" xml:space="preserve">
+    <value>生產</value>
+  </data>
+  <data name="调机" xml:space="preserve">
+    <value>調機</value>
+  </data>
+  <data name="流线" xml:space="preserve">
+    <value>流線</value>
+  </data>
 </root>

+ 9 - 0
TeamAAS-VM/Resources/Languages/Lang.resx

@@ -3269,4 +3269,13 @@
   <data name="SettingView_Language_Vietnamese" xml:space="preserve">
     <value>越南语</value>
   </data>
+  <data name="生产" xml:space="preserve">
+    <value>生产</value>
+  </data>
+  <data name="调机" xml:space="preserve">
+    <value>调机</value>
+  </data>
+  <data name="流线" xml:space="preserve">
+    <value>流线</value>
+  </data>
 </root>

+ 9 - 0
TeamAAS-VM/Resources/Languages/Lang.vi.resx

@@ -3174,4 +3174,13 @@
   <data name="SettingView_Language_Vietnamese" xml:space="preserve">
     <value>Tiếng Việt</value>
   </data>
+  <data name="生产" xml:space="preserve">
+    <value>sản xuất</value>
+  </data>
+  <data name="调机" xml:space="preserve">
+    <value>điều chỉnh máy</value>
+  </data>
+  <data name="流线" xml:space="preserve">
+    <value>đường dòng</value>
+  </data>
 </root>

+ 9 - 0
TeamAAS-VM/Resources/Languages/Lang.zh-TW.resx

@@ -3174,4 +3174,13 @@
   <data name="SettingView_Language_Vietnamese" xml:space="preserve">
     <value>越南語</value>
   </data>
+  <data name="生产" xml:space="preserve">
+    <value>生產</value>
+  </data>
+  <data name="调机" xml:space="preserve">
+    <value>調機</value>
+  </data>
+  <data name="流线" xml:space="preserve">
+    <value>流線</value>
+  </data>
 </root>

+ 3 - 2
TeamAAS-VM/Services/MesService.cs

@@ -10,6 +10,7 @@ using System.Threading.Tasks;
 using TeamAAS_VP.Enums;
 using TeamAAS_VP.Events;
 using TeamAAS_VP.Interfaces;
+using TeamAAS_VP.Models;
 
 namespace TeamAAS_VP.Services
 {
@@ -637,12 +638,12 @@ namespace TeamAAS_VP.Services
         /// <param name="cancellationToken"></param>
         /// <returns></returns>
         /// <exception cref="ObjectDisposedException"></exception>
-        public async Task<(bool IsSuccess, string Response)> SendFtpFileAsync(string sn, string name, CancellationToken cancellationToken = default)
+        public async Task<(bool IsSuccess, string Response)> SendFtpFileAsync(string sn, string name,DeviceInfo device, CancellationToken cancellationToken = default)
         {
             // 如果已经释放,则抛出异常,防止在已释放资源上继续操作。
             if (_disposed) throw new ObjectDisposedException(nameof(MesService));
 
-            var device = _configService.GetDeviceInfo();
+            //var device = _configService.GetDeviceInfo();
             if (device == null || !device.EnableMES)
             {
                 return (true, "MES功能未启用!");

+ 3 - 3
TeamAAS-VM/Views/MainWindowView.xaml

@@ -126,13 +126,13 @@
                                 VerticalAlignment="Center"
                                 FontWeight="Bold"/>
                         <materialDesign:Card HorizontalAlignment="Center" VerticalAlignment="Center" Margin="50,10" Background="{Binding management.RunModelBackground}" >
-                            <TextBlock Text="生产" FontSize="22" Margin="8" />
+                            <TextBlock Text="{lex:Loc 生产}" FontSize="22" Margin="8" />
                         </materialDesign:Card >
                         <materialDesign:Card HorizontalAlignment="Center" VerticalAlignment="Center" Margin="20,10" Background="{Binding management.ManualModeBackground}" >
-                            <TextBlock Text="调机" FontSize="22" Margin="8"/>
+                            <TextBlock Text="{lex:Loc 调机}" FontSize="22" Margin="8"/>
                         </materialDesign:Card>
                         <materialDesign:Card HorizontalAlignment="Center" VerticalAlignment="Center" Margin="50,10" Background="{Binding management.ClearModeBackground}" >
-                            <TextBlock Text="流线" FontSize="22" Margin="8" />
+                            <TextBlock Text="{lex:Loc 流线}" FontSize="22" Margin="8" />
                         </materialDesign:Card>
                     </StackPanel>
                 </materialDesign:Card>