Procházet zdrojové kódy

合并越南现场验证的版本

KWD před 3 měsíci
rodič
revize
d73075dd03

+ 79 - 57
TeamAAS-VM/Core/Management.cs

@@ -261,8 +261,8 @@ namespace TeamAAS_VP.Core
             set { SetProperty(ref _ProductList, value); }
         }
 
-        public static int uphhour=0;
-        public static int uphnumber=0;
+        public static int uphhour = 0;
+        public static int uphnumber = 0;
         #endregion
 
         #region 命令
@@ -1117,7 +1117,7 @@ namespace TeamAAS_VP.Core
         /// </summary>
         /// <returns></returns>
         public async Task WritePositionToPlcAsync()
-        {            
+        {
             var addressConfig = _configService.GetPlcAddresses();
             var plc = _plcService.GetPlcByNumber(addressConfig.PlcNo) as OpcUaClientPLC;
             if (plc == null || !plc.IsConnected) return;
@@ -1512,7 +1512,7 @@ namespace TeamAAS_VP.Core
                                                 item.U_Position += offsetAngle;
                                                 await item.WriteToPlcAddress(addressConfig.Out_RemovePos, plc);
                                             }
-                                        }                                                                               
+                                        }
 
                                         await plc.WriteNodeAsync(addressConfig.Out_DownCameraStatus.Address, (Int16)1);
                                         return;
@@ -2273,17 +2273,17 @@ namespace TeamAAS_VP.Core
                                 SendTaskMessage($"固定相机流程3结果:{visionResults[2].dis}", MessageLevel.Debug);
                                 SendTaskMessage($"固定相机流程4结果:{visionResults[3].dis}", MessageLevel.Debug);
                                 DISDict.Clear();
-                                DISDict.Add("DownDis1", visionResults[0].dis.Split(',')[1]);
-                                DISDict.Add("LeftDis1", visionResults[0].dis.Split(',')[2]);
+                                //DISDict.Add("DownDis1", visionResults[0].dis.Split(',')[1]);
+                                //DISDict.Add("LeftDis1", visionResults[0].dis.Split(',')[2]);
 
-                                DISDict.Add("LeftDis2", visionResults[1].dis.Split(',')[1]);
-                                DISDict.Add("UpDis1", visionResults[1].dis.Split(',')[2]);
+                                //DISDict.Add("LeftDis2", visionResults[1].dis.Split(',')[1]);
+                                //DISDict.Add("UpDis1", visionResults[1].dis.Split(',')[2]);
 
-                                DISDict.Add("DownDis2", visionResults[2].dis.Split(',')[1]);
-                                DISDict.Add("RightDis1", visionResults[2].dis.Split(',')[2]);
+                                //DISDict.Add("DownDis2", visionResults[2].dis.Split(',')[1]);
+                                //DISDict.Add("RightDis1", visionResults[2].dis.Split(',')[2]);
 
-                                DISDict.Add("UpDis2", visionResults[3].dis.Split(',')[1]);
-                                DISDict.Add("RightDis2", visionResults[3].dis.Split(',')[2]);
+                                //DISDict.Add("UpDis2", visionResults[3].dis.Split(',')[1]);
+                                //DISDict.Add("RightDis2", visionResults[3].dis.Split(',')[2]);
 
 
                             }
@@ -2295,17 +2295,17 @@ namespace TeamAAS_VP.Core
                                 SendTaskMessage($"固定相机流程3结果:{visionResults[2].dis}", MessageLevel.Debug);
                                 SendTaskMessage($"固定相机流程4结果:{visionResults[3].dis}", MessageLevel.Debug);
                                 DISDict.Clear();
-                                DISDict.Add("DownDis1", visionResults[0].dis.Split(',')[1]);
-                                DISDict.Add("LeftDis1", visionResults[0].dis.Split(',')[2]);
+                                //DISDict.Add("DownDis1", visionResults[0].dis.Split(',')[1]);
+                                //DISDict.Add("LeftDis1", visionResults[0].dis.Split(',')[2]);
 
-                                DISDict.Add("LeftDis2", visionResults[1].dis.Split(',')[1]);
-                                DISDict.Add("UpDis1", visionResults[1].dis.Split(',')[2]);
+                                //DISDict.Add("LeftDis2", visionResults[1].dis.Split(',')[1]);
+                                //DISDict.Add("UpDis1", visionResults[1].dis.Split(',')[2]);
 
-                                DISDict.Add("DownDis2", visionResults[2].dis.Split(',')[1]);
-                                DISDict.Add("RightDis1", visionResults[2].dis.Split(',')[2]);
+                                //DISDict.Add("DownDis2", visionResults[2].dis.Split(',')[1]);
+                                //DISDict.Add("RightDis1", visionResults[2].dis.Split(',')[2]);
 
-                                DISDict.Add("UpDis2", visionResults[3].dis.Split(',')[1]);
-                                DISDict.Add("RightDis2", visionResults[3].dis.Split(',')[2]);
+                                //DISDict.Add("UpDis2", visionResults[3].dis.Split(',')[1]);
+                                //DISDict.Add("RightDis2", visionResults[3].dis.Split(',')[2]);
 
 
                                 await plc.WriteNodeAsync(addressConfig.Out_FixedCameraPutStatus.Address, (Int16)2);
@@ -2381,6 +2381,15 @@ namespace TeamAAS_VP.Core
                                 await plc.WriteNodeAsync(addressConfig.Out_FixedCameracheckStatus.Address, (Int16)1);
                                 return;
                             }
+                            for (int i = 0; i < visionResults.Length; i++)
+                            {
+                                if (visionResults[i].distance.Length != 0)
+                                { }
+                                else
+                                {
+                                    visionResults[i].distance = $"{i + 1},999";
+                                }
+                            }
                             if (visionResults[0].IsSucceed && visionResults[1].IsSucceed && visionResults[2].IsSucceed && visionResults[3].IsSucceed)
                             {
                                 SendTaskMessage($"固定相机检测OK", MessageLevel.Debug);
@@ -2388,14 +2397,13 @@ namespace TeamAAS_VP.Core
                                 SendTaskMessage($"流程2结果:{visionResults[1].distance}", MessageLevel.Debug);
                                 SendTaskMessage($"流程3结果:{visionResults[2].distance}", MessageLevel.Debug);
                                 SendTaskMessage($"流程4结果:{visionResults[3].distance}", MessageLevel.Debug);
-
                                 gapDict.Clear();
                                 gapDict.Add("Gap1", visionResults[0].distance.Split(',')[1]);
                                 gapDict.Add("Gap2", visionResults[1].distance.Split(',')[1]);
                                 gapDict.Add("Gap3", visionResults[2].distance.Split(',')[1]);
                                 gapDict.Add("Gap4", visionResults[3].distance.Split(',')[1]);
-                                gapDict.Add("Gap5", visionResults[1].distance.Split(',')[2]);
-                                gapDict.Add("Gap6", visionResults[3].distance.Split(',')[2]);
+                                //gapDict.Add("Gap5", visionResults[1].distance.Split(',')[2]);
+                                //gapDict.Add("Gap6", visionResults[3].distance.Split(',')[2]);
                                 //gapString = $"{visionResults[0].distance.Split(',')[1]},{visionResults[1].distance.Split(',')[1]},{visionResults[2].distance.Split(',')[1]},{visionResults[3].distance.Split(',')[1]}";
                                 await plc.WriteNodeAsync(addressConfig.Out_FixedCameracheckStatus.Address, (Int16)1);
                                 return;
@@ -2407,16 +2415,16 @@ namespace TeamAAS_VP.Core
                                 res2 = visionResults[1].distance.Split(',')[1];
                                 res3 = visionResults[2].distance.Split(',')[1];
                                 res4 = visionResults[3].distance.Split(',')[1];
-                                res5 = visionResults[1].distance.Split(',')[2];
-                                res6 = visionResults[3].distance.Split(',')[2];
+                                //res5 = visionResults[1].distance.Split(',')[2];
+                                //res6 = visionResults[3].distance.Split(',')[2];
                                 SendTaskMessage($"固定相机检测NG", MessageLevel.Error);
                                 gapDict.Clear();
                                 gapDict.Add("Gap1", res1);
                                 gapDict.Add("Gap2", res2);
                                 gapDict.Add("Gap3", res3);
                                 gapDict.Add("Gap4", res4);
-                                gapDict.Add("Gap5", res5);
-                                gapDict.Add("Gap6", res6);
+                                //gapDict.Add("Gap5", res5);
+                                //gapDict.Add("Gap6", res6);
                                 //gapString = $"{res1},{res2},{res3},{res4}";
                                 await plc.WriteNodeAsync(addressConfig.Out_FixedCameracheckStatus.Address, (Int16)2);
                                 return;
@@ -2853,7 +2861,7 @@ namespace TeamAAS_VP.Core
                                                         if (currentProduct.ID != productId)
                                                         {
                                                             //切换产品
-                                                             _productService.LoadProduct(productId);
+                                                            _productService.LoadProduct(productId);
                                                             _productService.SetCurrentProduct(productId);
                                                             await WriteParameterToPlcExAsync();
                                                             SendTaskMessage($"切换产品成功", MessageLevel.Debug);
@@ -2937,7 +2945,7 @@ namespace TeamAAS_VP.Core
                                             {
                                                 revision[i] = revisionItem.Replace("stage=", "").Trim();
                                                 SendTaskMessage($"stage:{revision[i]}", MessageLevel.Info);
-                                            }    
+                                            }
                                             LogHelper.WriteLogMes($"询问mes成功");
                                             SendTaskMessage($"询问mes成功:{response}", MessageLevel.Debug);
 
@@ -2960,7 +2968,7 @@ namespace TeamAAS_VP.Core
                                                     if (currentProduct.ID != productId)
                                                     {
                                                         //切换产品
-                                                         _productService.LoadProduct(productId);
+                                                        _productService.LoadProduct(productId);
                                                         _productService.SetCurrentProduct(productId);
                                                         await WriteParameterToPlcExAsync();
                                                         SendTaskMessage($"切换产品成功", MessageLevel.Debug);
@@ -3096,7 +3104,7 @@ namespace TeamAAS_VP.Core
                                             }
                                             data = gapDict.Copy();
                                             data.Add("AssyPressure1", assypress);
-                                            SendTaskMessage($"Gap1:{gapDict["Gap1"]},Gap2:{gapDict["Gap2"]},Gap3:{gapDict["Gap3"]},Gap4:{gapDict["Gap4"]},Gap5:{gapDict["Gap5"]},Gap6:{gapDict["Gap6"]},组装压力:{assypress}", MessageLevel.Info);
+                                            SendTaskMessage($"Gap1:{gapDict["Gap1"]},Gap2:{gapDict["Gap2"]},Gap3:{gapDict["Gap3"]},Gap4:{gapDict["Gap4"]},组装压力:{assypress}", MessageLevel.Info);
                                         }
                                         catch (Exception ex)
                                         {
@@ -3184,7 +3192,7 @@ namespace TeamAAS_VP.Core
                                                 PROCESS_END_TIME = serverTimeResult.Now.ToString("yyyy-MM-ddTHH:mm:ss") + "+08:00",
                                                 SUPPLIER_NAME = stationConfig.DataInfo.SUPPLIER_NAME,
                                                 COMMODITY_TYPE = stationConfig.DataInfo.COMMODITY_TYPE,
-                                                REVISION = stationConfig.DataInfo.REVISION+"_"+ revision[i],
+                                                REVISION = stationConfig.DataInfo.REVISION + "_" + revision[i],
                                                 WO = wo[i],
                                                 MFG_LOT = stationConfig.DataInfo.MFG_LOT,
                                                 MFG_ASSY_LINE = stationConfig.DataInfo.MFG_ASSY_LINE,
@@ -3230,7 +3238,7 @@ namespace TeamAAS_VP.Core
 
                                         try
                                         {
-                                            SendTaskMessage($"左1:{DISDict["LeftDis1"]},下1:{DISDict["DownDis1"]},左2:{DISDict["LeftDis2"]},上1:{DISDict["UpDis1"]},右1:{DISDict["RightDis1"]},下2:{DISDict["DownDis2"]},右2:{DISDict["RightDis2"]},上2:{DISDict["UpDis2"]}", MessageLevel.Info);
+                                            //SendTaskMessage($"左1:{DISDict["LeftDis1"]},下1:{DISDict["DownDis1"]},左2:{DISDict["LeftDis2"]},上1:{DISDict["UpDis1"]},右1:{DISDict["RightDis1"]},下2:{DISDict["DownDis2"]},右2:{DISDict["RightDis2"]},上2:{DISDict["UpDis2"]}", MessageLevel.Info);
                                             if (i == 0)
                                             {
                                                 DFC2.Add(new DataFormCtq
@@ -3250,14 +3258,14 @@ namespace TeamAAS_VP.Core
                                                     MFG_LOT = stationConfig.DataInfo.MFG_LOT,//
                                                     MFG_ASSY_LINE = stationConfig.DataInfo.MFG_ASSY_LINE,
                                                     PROCESS_OUTCOME = "Pass",
-                                                    PROCESS_MACHINE_ID = DISDict["LeftDis1"],//左1
-                                                    CTQ_UNIT_OF_MEASURE = DISDict["DownDis1"],//下1
-                                                    ERROR_MESSAGE = DISDict["LeftDis2"],///左2
-                                                    PD_ATTR_01 = DISDict["UpDis1"],//上1
-                                                    PD_ATTR_02 = DISDict["RightDis1"],//右1
-                                                    PD_ATTR_03 = DISDict["DownDis2"],//下2
-                                                    PD_ATTR_04 = DISDict["RightDis2"],//右2
-                                                    PD_ATTR_05 = DISDict["UpDis2"],//上2
+                                                    //PROCESS_MACHINE_ID = DISDict["LeftDis1"],//左1
+                                                    //CTQ_UNIT_OF_MEASURE = DISDict["DownDis1"],//下1
+                                                    //ERROR_MESSAGE = DISDict["LeftDis2"],///左2
+                                                    //PD_ATTR_01 = DISDict["UpDis1"],//上1
+                                                    //PD_ATTR_02 = DISDict["RightDis1"],//右1
+                                                    //PD_ATTR_03 = DISDict["DownDis2"],//下2
+                                                    //PD_ATTR_04 = DISDict["RightDis2"],//右2
+                                                    //PD_ATTR_05 = DISDict["UpDis2"],//上2
                                                 });
                                             }
                                             bool recordResult2 = RecordStationResult2(i, DFC2, ProductMainSN[i], serverTimeResult.Now.Subtract(_LastMesCheckTime[i]).TotalSeconds, _LastMesCheckTime[i], stationConfig.SaveCsvPath);
@@ -3291,7 +3299,7 @@ namespace TeamAAS_VP.Core
                                                 {
                                                     fileresult.Add($"Pressure1_File");
                                                 }
-                                               // resultIndex = 2;
+                                                // resultIndex = 2;
                                             }
                                         }
                                         catch (Exception ex)
@@ -3371,7 +3379,7 @@ namespace TeamAAS_VP.Core
                                     }
 
                                     //gap-复检gap参数, press-保压站实际压力值, presstime-保压站保压时间, assypress-组装站实际压力值
-                                    (bool isSuccess, string response) = await _mesService.SubmitGetAsync(i, ProductMainSN[i], comp, resultIndex == 1 ? true : false, data,fileresult, _LastMesCheckTime[i], serverTimeResult.Now);
+                                    (bool isSuccess, string response) = await _mesService.SubmitGetAsync(i, ProductMainSN[i], comp, resultIndex == 1 ? true : false, data, fileresult, _LastMesCheckTime[i], serverTimeResult.Now);
                                     if (!stationConfig.EnableMES || isSuccess)
                                     {
                                         LogHelper.WriteLogMes($"上传mes成功");
@@ -3382,7 +3390,7 @@ namespace TeamAAS_VP.Core
                                         LogHelper.WriteLogMes($"上传mes失败");
                                         SendTaskMessage($"上传mes失败", MessageLevel.Error);
                                     }
-                                   
+
 
                                     //是否保存当前的产品记录至CSV?
                                     if (stationConfig.SaveCsv)
@@ -3425,7 +3433,7 @@ namespace TeamAAS_VP.Core
                                                             string target_log = Path.Combine(filePath, Path.GetFileName(source_log));
                                                             File.Copy(source_log, target_log, true);
                                                             //判断是否保存锁付曲线
-                                                            if (pressureSensorConfig.IsSavePressureCurve&&i!=0)
+                                                            if (pressureSensorConfig.IsSavePressureCurve && i != 0)
                                                             {
                                                                 string target_Directory = filePath + "\\压力曲线\\";
                                                                 string source_Torque_Image = pressureSensorConfig.PressureCurvePath + $"\\{dt.ToString("yyyy-MM")}\\{dt.ToString("yyyy-MM-dd")}\\{currentProduct.Name}\\{ProductMainSN[i]}";
@@ -3503,7 +3511,7 @@ namespace TeamAAS_VP.Core
                                     }
                                     LogHelper.WriteLogMes($"【mes结束ADD】");
                                     SendTaskMessage($"mes结束ADD", MessageLevel.Info);
-                                    fileresult.Clear();                                   
+                                    fileresult.Clear();
                                     await plc.WriteNodeAsync(string.Format(addressConfig.Out_MesStatus.Address, i), (Int16)3);
                                     return;
                                 }
@@ -3586,7 +3594,7 @@ namespace TeamAAS_VP.Core
                                         {
                                             await plc.WriteNodeAsync(string.Format(addressConfig.In_WorkDone.Address, i), (Int16)3);//OK
                                         }
-                                    }                                    
+                                    }
                                 }
                                 else
                                 {
@@ -3630,9 +3638,9 @@ namespace TeamAAS_VP.Core
 
                 for (int i = 0; i < allDevices.Count; i++)
                 {
-                     var stationConfig =  allDevices.FirstOrDefault(d => d.DeviceNo == i);
+                    var stationConfig = allDevices.FirstOrDefault(d => d.DeviceNo == i);
                     //var stationConfig = _configService.GetDeviceInfo(i);
-                    if (!string.IsNullOrEmpty(stationConfig.Station) && stationConfig.Station != ""&&!string.IsNullOrEmpty(stationConfig.DeviceName) && stationConfig.DeviceName != "")
+                    if (!string.IsNullOrEmpty(stationConfig.Station) && stationConfig.Station != "" && !string.IsNullOrEmpty(stationConfig.DeviceName) && stationConfig.DeviceName != "")
                     {
                         if (!stationConfig.EnableMES || !stationConfig.EnableDoubleMes || !stationConfig.SaveCsv)
                         {
@@ -3640,7 +3648,7 @@ namespace TeamAAS_VP.Core
                             mesStatus = false;
                             break;
                         }
-                    }    
+                    }
                 }
                 //var systemConfig = _configService.GetSystemConfiguration();
                 //if (!systemConfig.PressureSensorConfig[0].IsSavePressureCurve || !systemConfig.PressureSensorConfig[1].IsSavePressureCurve)
@@ -3665,7 +3673,7 @@ namespace TeamAAS_VP.Core
 
             }
             var user = _systemDatabaseService.GetCurrentUser();
-            if (connectStaus && mesStatus && _LastAutoRunning&& user.userPart == UserPart.Operator)
+            if (connectStaus && mesStatus && _LastAutoRunning && user.userPart == UserPart.Operator)
             {
                 RunModelBackground = System.Windows.Media.Brushes.Green;
                 ClearModeBackground = System.Windows.Media.Brushes.White;
@@ -3879,12 +3887,26 @@ namespace TeamAAS_VP.Core
                 var currentproduct = _productService.GetCurrentProduct();
                 if (currentproduct == null) return;
                 TotalQuantity = await _systemDatabaseService.GetOverallProductionAsync(currentproduct.Name);
-                TotalQuantityToday = await _systemDatabaseService.GetTodayProductionAsync(currentproduct.Name);
-                CurrentUPH = await _systemDatabaseService.GetLastHourProductionAsync(currentproduct.Name);
-                //
+                //TotalQuantityToday = await _systemDatabaseService.GetTodayProductionAsync(currentproduct.Name);
+                //CurrentUPH = await _systemDatabaseService.GetLastHourProductionAsync(currentproduct.Name);
+                ////
                 ThrowNumber = await _systemDatabaseService.GetThrowNumberAsync();
-                NgNumber = await _systemDatabaseService.GetNGProductionAsync(currentproduct.Name);
-                Yield = ((double)TotalQuantityToday - (double)NgNumber) / (double)TotalQuantityToday * 100;
+                //NgNumber = await _systemDatabaseService.GetNGProductionAsync(currentproduct.Name);
+                //Yield = ((double)TotalQuantityToday - (double)NgNumber) / (double)TotalQuantityToday * 100;
+
+                TotalQuantityToday = 0;
+                CurrentUPH = 0;
+                NgNumber = 0;
+                Yield = 0;
+                ObservableCollection<ProductModel> ProductList = new ObservableCollection<ProductModel>(_productService.GetAllProducts());
+                foreach (var product in ProductList)
+                {
+                    //TotalQuantity += await _systemDatabaseService.GetOverallProductionAsync(product.Name);
+                    TotalQuantityToday += await _systemDatabaseService.GetTodayProductionAsync(product.Name);
+                    CurrentUPH += await _systemDatabaseService.GetLastHourProductionAsync(product.Name);
+                    NgNumber += await _systemDatabaseService.GetNGProductionAsync(product.Name);
+                }
+                Yield += ((double)TotalQuantityToday - (double)NgNumber) / (double)TotalQuantityToday * 100;
             }
             catch (Exception)
             {
@@ -4006,7 +4028,7 @@ namespace TeamAAS_VP.Core
                 string tempDirPath = Path.Combine(savePath, datePath, $"{stationIndex}_{timestamp.ToString("yyyy-MM-dd")}_temp");
                 string tempFileName = $"{stationIndex}_{timestamp.ToString("yyyy-MM-dd_HH-mm-ss-fff")}_temp.csv";
                 RecordStationResult(stationIndex, dfcs, productMainSN, ct, timestamp, tempFileName, false);
-                return false;                
+                return false;
             }
         }
         private bool RecordStationResult2(int stationIndex, IEnumerable<DataFormCtq> dfcs, string productMainSN, double ct, DateTime timestamp, string savePath, bool isFirstEnter = true)

+ 16 - 0
TeamAAS-VM/ViewModels/HomeViewModel.cs

@@ -170,6 +170,14 @@ namespace TeamAAS_VP.ViewModels
 
         // 可选:记录传感器 Id -> 索引 的映射,便于外部(如 Management)按 Id 更新
         private readonly Dictionary<string, int> _sensorIdToIndex = new Dictionary<string, int>();
+
+        private bool _IsAllowEdit = false;
+
+        public bool IsAllowEdit
+        {
+            get { return _IsAllowEdit; }
+            set { SetProperty(ref _IsAllowEdit, value); }
+        }
         #endregion
 
         #region 命令
@@ -611,6 +619,14 @@ namespace TeamAAS_VP.ViewModels
         public async void OnNavigatedTo(NavigationContext navigationContext)
         {
 
+            if (_systemDatabaseService.GetCurrentUser().userPart == Enums.UserPart.Operator || _systemDatabaseService.GetCurrentUser().userPart == Enums.UserPart.Engineer)
+            {
+                IsAllowEdit = false;
+            }
+            else
+            {
+                IsAllowEdit = true;
+            }
             try
             {
                 ProductList = new ObservableCollection<ProductModel>(_productService.GetAllProducts());

+ 1 - 0
TeamAAS-VM/Views/HomeView.xaml

@@ -467,6 +467,7 @@ VerticalAlignment="Center">
                         VerticalAlignment="Bottom"
                         Margin=" 10,3"
                         HorizontalAlignment="Right"
+                        IsEnabled="{Binding IsAllowEdit}"
                         materialDesign:ButtonAssist.CornerRadius="10"
                         Style="{StaticResource MaterialDesignRaisedButton}"
                         Command="{Binding ResetCounterCommand}" />