From a5ca8352f035f95d23717e49b74a6c6aea8a9fc9 Mon Sep 17 00:00:00 2001
From: huangxiaoqiang <1247017146@qq.com>
Date: 星期三, 02 四月 2025 16:03:12 +0800
Subject: [PATCH] 添加MOM异常信息页面,OCV管理页面,优化WCS不能添加用户信息问题,优化分容空框回流写入线体信息失败问题

---
 CodeManagement/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_GW/CommonConveyorLine_GWJob.cs |  124 ++++++++++++++++++++---------------------
 1 files changed, 61 insertions(+), 63 deletions(-)

diff --git a/CodeManagement/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_GW/CommonConveyorLine_GWJob.cs b/CodeManagement/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_GW/CommonConveyorLine_GWJob.cs
index ad8822c..59fdf01 100644
--- a/CodeManagement/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_GW/CommonConveyorLine_GWJob.cs
+++ b/CodeManagement/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_GW/CommonConveyorLine_GWJob.cs
@@ -19,10 +19,13 @@
 
 #endregion << 鐗� 鏈� 娉� 閲� >>
 
+using Autofac.Core;
 using AutoMapper;
 using HslCommunication;
 using Microsoft.CodeAnalysis;
 using Newtonsoft.Json;
+using OfficeOpenXml.FormulaParsing.Excel.Functions.Math;
+using OfficeOpenXml.FormulaParsing.Excel.Functions.RefAndLookup;
 using Quartz;
 using SqlSugar;
 using System.Reflection;
@@ -119,15 +122,7 @@
                     List<string> childDeviceCodes = _routerService.QueryAllPositions(conveyorLine.DeviceCode);
                     foreach (string childDeviceCode in childDeviceCodes)
                     {
-                        ConveyorLineTaskCommand_After command = null;
-                        if (childDeviceCode == "2236")
-                        {
-                            var stationPLC = _stationManagerRepository.QueryFirst(x => x.stationType == 1 && x.stationChildCode == childDeviceCode).stationPLC;
-                            IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == stationPLC);
-                            CommonConveyorLine_After conveyorLine1 = (CommonConveyorLine_After)device;
-                            command = conveyorLine1.ReadCustomer<ConveyorLineTaskCommand_After>(childDeviceCode);
-                        }
-
+                        ConveyorLineTaskCommand_After command = conveyorLine.ReadCustomer<ConveyorLineTaskCommand_After>(childDeviceCode);
                         if (command == null) continue;
                         if (command.ConveyorLineBarcode.Trim().Contains("\0")) command.ConveyorLineBarcode = "";
 
@@ -141,7 +136,7 @@
                             }
                         }
 
-                        if (childDeviceCode == "1670"||childDeviceCode=="1666"||childDeviceCode=="1548"||childDeviceCode=="1448")
+                        if (childDeviceCode == "3464" || childDeviceCode == "3460" || childDeviceCode == "3456" )
                         {
                             Platform platform = _platFormRepository.QueryFirst(x => x.PLCCode == conveyorLine.DeviceCode && x.PlatCode == childDeviceCode && x.Status == "Active");
                             if (platform != null)
@@ -307,10 +302,10 @@
 
                 //ConveyorLineSendFinish(conveyorLine, childDeviceCode, ProtocalDetailValue, true);
                 _taskService.UpdateTaskStatusToNext(task);
-                if (task.TaskType == (int)TaskOutboundTypeEnum.OutTray)
-                {
-                    _taskService.UpdateTaskStatusToNext(task);
-                }
+                //if (task.TaskType == (int)TaskOutboundTypeEnum.OutTray)
+                //{
+                //    _taskService.UpdateTaskStatusToNext(task);
+                //}
             }
         }
 
@@ -380,59 +375,61 @@
         /// <param name="childDeviceCode">瀛愯澶囩紪鍙�</param>
         public void ConveyorLineOutFinish(CommonConveyorLine_GW conveyorLine, ConveyorLineTaskCommand_After command, string childDeviceCode)
         {
-            var task = _taskService.QueryExecutingConveyorLineTask(command.ConveyorLineTaskNum, childDeviceCode);
-            if (task != null)
+            try
             {
-                WebResponseContent content = new WebResponseContent();
-                ConveyorLineTaskCommand_After taskCommand = _mapper.Map<ConveyorLineTaskCommand_After>(task);
-                taskCommand.InteractiveSignal = command.InteractiveSignal;
-                Dt_StationManager stationManager = _stationManagerRepository.QueryFirst(x => x.stationPLC == conveyorLine.DeviceCode && x.stationChildCode == childDeviceCode);
-                if (task.PalletCode != command.ConveyorLineBarcode)
+                var task = _taskService.QueryExecutingConveyorLineTask(command.ConveyorLineTaskNum, childDeviceCode);
+                if (task != null)
                 {
-                    //var NGAddress = _platFormRepository.QueryFirst(x => x.PlatCode == task.TargetAddress).Capacity;
-                    //taskCommand.ConveyorLineTargetAddress = (short)NGAddress;
-                    taskCommand.ConveyorLineTargetAddress = Convert.ToInt16(stationManager.stationNGChildCode);
-                }
-                else
-                {
-                    //Dt_StationManager stationManager = _stationManagerRepository.QueryFirst(x => x.stationPLC == conveyorLine.DeviceCode && x.stationChildCode == childDeviceCode);
-                    taskCommand.ConveyorLineTargetAddress = Convert.ToInt16(stationManager.stationLocation);
-                }
-
-                if (stationManager.stationPLC == "1018" && stationManager.stationArea == "Cache")  //鏇存柊鍦ㄩ�旀暟鎹�
-                {
-                    dt_needBarcode needBarcode = _needBarcodeRepository.QueryFirst(x => x.productLine == stationManager.productLine && x.toArea == stationManager.stationChildCode);
-
-                    if (needBarcode != null)
+                    WebResponseContent content = new WebResponseContent();
+                    ConveyorLineTaskCommand_After taskCommand = _mapper.Map<ConveyorLineTaskCommand_After>(task);
+                    taskCommand.InteractiveSignal = command.InteractiveSignal;
+                    Dt_StationManager stationManager = _stationManagerRepository.QueryFirst(x => x.stationPLC == conveyorLine.DeviceCode && x.stationChildCode == childDeviceCode);
+                    if (task.PalletCode != command.ConveyorLineBarcode)
                     {
-                        needBarcode.inLineNum--;
-                        _needBarcodeRepository.UpdateData(needBarcode);
+                        //var NGAddress = _platFormRepository.QueryFirst(x => x.PlatCode == task.TargetAddress).Capacity;
+                        //taskCommand.ConveyorLineTargetAddress = (short)NGAddress;
+                        taskCommand.ConveyorLineTargetAddress = Convert.ToInt16(stationManager.stationNGChildCode);
                     }
+                    else
+                    {
+                        //Dt_StationManager stationManager = _stationManagerRepository.QueryFirst(x => x.stationPLC == conveyorLine.DeviceCode && x.stationChildCode == childDeviceCode);
+                        taskCommand.ConveyorLineTargetAddress = Convert.ToInt16(stationManager.stationLocation);
+                    }
+
+                    if (stationManager.stationPLC == "1007" && stationManager.stationArea == "Cache")  //鏇存柊鍦ㄩ�旀暟鎹�
+                    {
+                        dt_needBarcode needBarcode = _needBarcodeRepository.QueryFirst(x => x.productLine == stationManager.productLine && x.toArea == stationManager.stationChildCode);
+
+                        if (needBarcode != null)
+                        {
+                            if (needBarcode.inLineNum == 0 || needBarcode.inLineNum > 0)
+                            {
+                                needBarcode.inLineNum = 0;
+                            }
+                            else
+                            {
+                                needBarcode.inLineNum--;
+                            }
+                            _needBarcodeRepository.UpdateData(needBarcode);
+                        }
+                    }
+                    content = _taskService.UpdateTaskStatusToNext(task);
+                    var proAddress = conveyorLine.DeviceProDTOs
+                                    .FirstOrDefault(x => x.DeviceChildCode == childDeviceCode && x.DeviceProParamName == ConveyorLineDBName_After.InteractiveSignal.ToString())
+                                    ?.DeviceProAddress;
+                    string address = proAddress.Contains(".0") ? proAddress : proAddress + ".0";
+                    conveyorLine.SetValue(ConveyorLineDBName_After.ConveyorLineTaskNum, taskCommand.ConveyorLineTaskNum, childDeviceCode);
+                    conveyorLine.SetValue(ConveyorLineDBName_After.ConveyorLineTargetAddress, taskCommand.ConveyorLineTargetAddress, childDeviceCode);
+                    conveyorLine.SetValue(ConveyorLineDBName_After.ConveyorLineBarcode, taskCommand.ConveyorLineBarcode, childDeviceCode);
+                    conveyorLine.Communicator.Write(address, 1);
+                    //conveyorLine.SetValue(ConveyorLineDBName_After.InteractiveSignal, taskCommand.InteractiveSignal, childDeviceCode);
+                    //conveyorLine.SetValue(ConveyorLineDBName_After.ResponState, 1, childDeviceCode);
                 }
-
-                conveyorLine.SendCommand(taskCommand, childDeviceCode);
-                conveyorLine.SetValue(ConveyorLineDBName_After.ResponState, 1, childDeviceCode);
-                //ConveyorLineSendFinish(conveyorLine, childDeviceCode, ProtocalDetailValue, true);
-                content = _taskService.UpdateTaskStatusToNext(task);
             }
-            //else
-            //{
-            //    Dt_StationManager stationManager = _stationManagerRepository.QueryFirst(x => x.stationPLC == conveyorLine.DeviceCode && x.stationChildCode == childDeviceCode && x.stationArea == "Cache");
-            //    ////鏌ヨ瀵瑰簲浜х嚎鐨勫湪閫旀暟鎹�
-            //    //dt_needBarcode needBarcode = _needBarcodeRepository.QueryFirst(x => x.productLine == station.productLine);
-
-            //    //needBarcode.inLineNum = _taskRepository.QueryData(x => x.TargetAddress == station.stationChildCode).Count();
-
-            //    //鑻ュ湪閫旀暟閲忓皬浜庣洰鏍囦綅缃殑缂撳瓨鏁伴噺 鍒欏鎵惧搴斿父娓╁簱瀛樹腑甯告俯3宸ュ簭鐨勫彲鍑哄簱鏁版嵁 骞跺缓绔嬪嚭搴撲换鍔�
-            //    //if (needBarcode.inLineNum <= needBarcode.cacheNum)
-            //    //{
-            //    //}
-            //    //濡傛灉鍖呰缂撳瓨绔欏彴瀛樺湪 涓旀湁璇锋眰  鍒�
-            //    if (stationManager != null)
-            //    {
-            //        _taskService.RequestOutTaskToBZAsync(stationManager);
-            //    }
-            //}
+            catch (Exception ex)
+            {
+                WriteInfo($"{conveyorLine.DeviceName}杈撻�佺嚎鍑哄簱瀹屾垚", $"寮傚父淇℃伅銆恵JsonConvert.SerializeObject(ex.Message)}銆�,瀛愯妭鐐广�恵childDeviceCode}銆戞墭鐩樺彿锛氥�恵command.ConveyorLineBarcode}銆�");
+            }
         }
 
         /// <summary>
@@ -458,10 +455,11 @@
         /// <param name="command">璇诲彇鐨勮姹備俊鎭�</param>
         /// <param name="childDeviceCode">瀛愯澶囩紪鍙�</param>
         /// <param name="index">绾夸綋褰撳墠bool璇诲彇鍋忕Щ鍦板潃</param>
-        public async void EmptyTrayReturn(CommonConveyorLine_GW conveyorLine, ConveyorLineTaskCommand_After command, string childDeviceCode, int index, WIDESEAWCS_Model.Models.Platform platform)
+        public async void EmptyTrayReturn(CommonConveyorLine_GW conveyorLine, ConveyorLineTaskCommand_After command, string childDeviceCode, int index, Platform platform)
         {
             try
             {
+                //WriteInfo("鍑哄簱", $"銆恵JsonConvert.SerializeObject(platform)}銆�");
                 TaskOutboundTypeEnum taskOutboundTypeEnum;
                 if (platform.PlatformType.Contains("OutTray"))
                     taskOutboundTypeEnum = TaskOutboundTypeEnum.OutTray;
@@ -510,7 +508,7 @@
                     return;
 
                 taskDTO = JsonConvert.DeserializeObject<WMSTaskDTO>(content.Data.ToString());
-
+                //WriteInfo("鍑哄簱", $"銆恵JsonConvert.SerializeObject(taskDTO)}銆�");
                 #endregion 璋冪敤WMS鑾峰彇鍑哄簱浠诲姟
 
                 CreateAndSendTask(taskDTO);

--
Gitblit v1.9.3