From 8c8a68df710d568f5f2b358c1e8c4b4799547d0b Mon Sep 17 00:00:00 2001
From: huanghongfeng <huanghongfeng@hnkhzn.com>
Date: 星期五, 31 十月 2025 15:24:34 +0800
Subject: [PATCH] 安全门,出入库

---
 代码管理/WCS/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/CommonConveyorLineJob.cs |  224 +++++++++++++++++++++++++++++++++++--------------------
 1 files changed, 142 insertions(+), 82 deletions(-)

diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/CommonConveyorLineJob.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/CommonConveyorLineJob.cs"
index bd5e5f3..b705d00 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/CommonConveyorLineJob.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/CommonConveyorLineJob.cs"
@@ -1,24 +1,16 @@
-锘縰sing Autofac.Core;
-using AutoMapper;
+锘縰sing AutoMapper;
 using Quartz;
-using System.Diagnostics.CodeAnalysis;
-using System.Reflection;
-using System.Threading.Tasks;
 using WIDESEA_Common.Log;
-using WIDESEAWCS_Common.TaskEnum;
 using WIDESEAWCS_Core;
-using WIDESEAWCS_Core.Helper;
 using WIDESEAWCS_DTO.Enum;
 using WIDESEAWCS_ISystemServices;
 using WIDESEAWCS_ITaskInfoService;
 using WIDESEAWCS_Model.Models;
-using WIDESEAWCS_Model.Models.System;
 using WIDESEAWCS_QuartzJob;
 using WIDESEAWCS_QuartzJob.DTO;
 using WIDESEAWCS_QuartzJob.Service;
 using WIDESEAWCS_Tasks.ConveyorLineJob;
 using WIDESEAWCS_Tasks.StackerCraneJob;
-using static System.Collections.Specialized.BitVector32;
 
 namespace WIDESEAWCS_Tasks
 {
@@ -30,14 +22,18 @@
         private readonly IRouterService _routerService;
         private readonly IAgvStationService _agvStationService;
         private readonly IMapper _mapper;
+        private readonly IRgvOperationService _gvOperationService;
+        private readonly IEquipmentStatusService _equipmentStatusService;
 
-        public CommonConveyorLineJob(ITaskService taskService, ITaskExecuteDetailService taskExecuteDetailService, IRouterService routerService, IAgvStationService agvStation, IMapper mapper)
+        public CommonConveyorLineJob(ITaskService taskService, ITaskExecuteDetailService taskExecuteDetailService, IRouterService routerService, IAgvStationService agvStation, IMapper mapper, IRgvOperationService gvOperationService, IEquipmentStatusService equipmentStatusService)
         {
             _taskService = taskService;
             _taskExecuteDetailService = taskExecuteDetailService;
             _routerService = routerService;
             _agvStationService = agvStation;
             _mapper = mapper;
+            _gvOperationService = gvOperationService;
+            _equipmentStatusService=equipmentStatusService;
         }
 
         public async Task Execute(IJobExecutionContext context)
@@ -47,56 +43,26 @@
                 CommonConveyorLine conveyorLine = (CommonConveyorLine)context.JobDetail.JobDataMap.Get("JobParams");
                 if (conveyorLine != null)
                 {
+                    
+
                     //鏍规嵁璁惧鏌ユ壘鍑哄搴旂殑绔欏彴淇℃伅
-                    /*List<AGVStation> aGVStations = _agvStationService.GetYljSide(conveyorLine.DeviceCode);
+                    List<AGVStation> aGVStations = _agvStationService.GetYljSide(conveyorLine.DeviceCode);
                     foreach (var Stations in aGVStations)
                     {
-                        PlatformStatus aQMConveyor = StoticCommand(conveyorLine, Stations.ChildPosiDeviceCode);
-                        if(aQMConveyor.HCJ_GoodsStatus==0)    //鍙繘琛屾斁璐�
+                        if (Stations.Station_material == (int)RGVEquipment.AQMexit)
                         {
-                            WebResponseContent webResponseContent = new WebResponseContent();
-                            //鏍规嵁绫诲瀷鏌ユ壘浠诲姟
-                            if (Stations.Station_material== (int)RGVEquipment.AbnormalOutbound)
-                            {
-                                //鏌ユ壘鏄惁鏈夊紓甯告惉杩愪换鍔�
-                                webResponseContent = _taskService.UpdateDeliveryAddress(Stations.HCJStorageaddress.ToString(), 1);   //杩橀渶瑕佷紶鍏ュ湴鍧�
-                            }
-                            else
-                            {
-                                //鍑哄簱绔欏彴鐨勪换鍔�
-                                webResponseContent = _taskService.UpdateDeliveryAddress(Stations.HCJStorageaddress.ToString(), 2);
-                            }
 
+                            bool Security = SecurityDoorEquipment(conveyorLine, Stations);
+                            if (Security) continue;
 
                         }
-                    }*/
-
-
-
-                    /*
-                    //瀹夊叏闂ㄥ紑闂ㄧ敵璇�+瀹夊叏闂ㄧ姸鎬�  1
-                    if(aQMConveyor.DoorRequest==1)
-                    {
-                        if(aQMConveyor.ResetStatus == 1)
+                        else
                         {
-                            //鍐欏叆杈撻�佺嚎杩涜鍒囨崲淇″彿
-                            var deviceProDtqh = GetDeviceProDTO(conveyorLine, "AQM001", "IndicatorStatus", "DeviceCommand");
-                            bool handoffbool = conveyorLine.Communicator.Write(deviceProDtqh.DeviceProDataBlock, (short)3);
-                            if (handoffbool)
-                            {
-                                //闇�瑕佸垽鏂璻gv锛屽爢鍨涙満鏄惁鍏佽寮�闂�
-
-                                //濡傛灉鍏佽寮�闂紝鍒欏啓鍏�4锛岃〃绀哄垏鎹㈡垚鍔燂紝
-                                bool Maintenancebool = conveyorLine.Communicator.Write(deviceProDtqh.DeviceProDataBlock, (short)4);
-                            }
+                            bool HCJPlat=PlatformEquipmentInformation(conveyorLine, Stations);
+                            if (HCJPlat) continue;
                         }
+                        
                     }
-                    else
-                    {
-                        //璇诲彇DBW8=1,DBW6=1,DBW10=1,DBW4=1,绗﹀悎鍚庯紝杩涜鍐欏叆鍒囨崲鐘舵�丏BW0=3
-                        AQMReturnnormal aQMReturnnormal=AQMStoticCommand(conveyorLine, "AQM001");   //鍒ゆ柇
-
-                    }*/
                 }
             }
             catch (Exception ex)
@@ -106,55 +72,147 @@
             return;
         }
 
-
-        public AQMConveyorRgvommand AQMCommand(CommonConveyorLine conveyorLine, string kladder)
+       
+        //澶勭悊瀹夊叏闂ㄧ殑閫昏緫
+        private void HandleDoorRequest(AQMReturnnormal aQMConveyor, AGVStation aGVStation,int tasktype)  //1锛氬叆搴�  2锛氬嚭搴�
         {
-            AQMConveyorRgvommand conveyorRgvCommand = new AQMConveyorRgvommand();
-            List<DeviceProDTO> deviceProDTO6 = conveyorLine.DeviceProDTOs
-                .Where(x => x.DeviceChildCode == kladder
-                            && DBLine.ConveyorAQMCommand.Contains(x.DeviceProParamName)
-                            && x.DeviceProParamType == "ReadDeviceCommand")
-                .ToList();
-            foreach (var item in deviceProDTO6)
+            if (_gvOperationService.AQMReadAlarminform(tasktype) && _equipmentStatusService.GetSCstatus())
             {
-                var paramName = item.DeviceProParamName;
-                var propertyInfo = typeof(AQMConveyorRgvommand).GetProperty(paramName);
+                //鍐欏叆鎶ヨ
+                GetDeviceAddress.WriteSecurityDoorpolice(aGVStation.ChildPosiDeviceCode, "AlarmSummary", 1);
+                _gvOperationService.WriteOutbuttonpause(null);
+            }
 
-                if (propertyInfo != null)
+            if (aQMConveyor.DoorRequest == 1 && aQMConveyor.IndicatorStatus == (int)SafetyDoorStatus.YellowBlink2Hz)
+            {
+                if (aQMConveyor.EmergencyStopStatus == 1)
                 {
-                    if (item.DeviceDataType == "int")
+                    bool AQMzckm = tasktype == 1 ? GetDeviceAddress.InRGVRGVStepprocess() : GetDeviceAddress.OutRGVRGVStepprocess();    //鍒ゆ柇鏄惁鏈夎繘绋嬩换鍔�
+                    if (AQMzckm)
                     {
-                        var value = conveyorLine.Communicator.Read<short>(item.DeviceProAddress);
-                        propertyInfo.SetValue(conveyorRgvCommand, value);
+                        //鍐欏叆鍋滄鐨勪俊鎭�
+                        bool RGVRGV_DWorkingmode = tasktype == 1 ? _gvOperationService.InWriteOutbuttonpause(null).Status : _gvOperationService.WriteOutbuttonpause(null).Status;
+
+                        bool RGVstate = tasktype == 1 ? GetDeviceAddress.InRGVStatice() : GetDeviceAddress.OutRGVStatice();     //鍒ゆ柇鏄惁鍏ㄤ负鎵嬪姩
+                        if (RGVstate)
+                        {
+                            //鍐欏叆寮�闂ㄤ俊鍙�
+                            GetDeviceAddress.WriteSecurityDoorpolice(aGVStation.ChildPosiDeviceCode, "OpenDoor", 1);
+                        }
                     }
+
+                }
+                else
+                {
+                    bool AQMkm = tasktype == 1 ? GetDeviceAddress.InRGVStatice() : GetDeviceAddress.OutRGVStatice();
+                    if (AQMkm)
+                    {
+                        GetDeviceAddress.WriteSecurityDoorpolice(aGVStation.ChildPosiDeviceCode, "OpenDoor", 1);
+                    }
+                    
                 }
             }
-            return conveyorRgvCommand;
         }
 
-        public AQMReturnnormal AQMStoticCommand(CommonConveyorLine conveyorLine, string kladder)
+        //瀹夊叏闂ㄨ澶囦俊鎭鐞�
+        private bool SecurityDoorEquipment(CommonConveyorLine conveyorLine, AGVStation Stations)
         {
-            AQMReturnnormal conveyorRgvCommand = new AQMReturnnormal();
-            List<DeviceProDTO> deviceProDTO6 = conveyorLine.DeviceProDTOs
-                .Where(x => x.DeviceChildCode == kladder
-                            && DBLine.ConveyorAQMReturnnormal.Contains(x.DeviceProParamName)
-                            && x.DeviceProParamType == "ReadDeviceCommand")
-                .ToList();
-            foreach (var item in deviceProDTO6)
+            try
             {
-                var paramName = item.DeviceProParamName;
-                var propertyInfo = typeof(AQMReturnnormal).GetProperty(paramName);
+                // 鑾峰彇瀹夊叏闂ㄤ俊鎭�
+                AQMReturnnormal aQMConveyor = AQMStoticCommand(conveyorLine, Stations.ChildPosiDeviceCode);
 
-                if (propertyInfo != null)
+                if (aQMConveyor.SafetyLockStatus == 1)
                 {
-                    if (item.DeviceDataType == "int")
+                    //鍐欏叆鎶ヨ
+                    GetDeviceAddress.WriteSecurityDoorpolice(Stations.ChildPosiDeviceCode, "AlarmSummary", 0);
+                    //鍐欏叆寮�闂ㄤ俊鍙�
+                    GetDeviceAddress.WriteSecurityDoorpolice(Stations.ChildPosiDeviceCode, "OpenDoor", 0);
+                }
+
+                // 鏍规嵁浠诲姟绫诲瀷閫夋嫨澶勭悊绛栫暐
+                if (Stations.Station_tasktype == (int)RGVTasktype.Outbound)
+                {
+                    if (aQMConveyor.EmergencyStopStatus == 0) _gvOperationService.WriteOutbuttonpause(null);
+                    HandleDoorRequest(aQMConveyor, Stations, 2);
+                }
+                else
+                {
+                    if (aQMConveyor.EmergencyStopStatus == 0) _gvOperationService.InWriteOutbuttonpause(null);
+                    HandleDoorRequest(aQMConveyor, Stations, 1);
+                }
+                return false;
+            }
+            catch (Exception ex)
+            {
+                return true;
+                throw;
+            }
+        }
+
+        private bool PlatformEquipmentInformation(CommonConveyorLine conveyorLine, AGVStation Stations)
+        {
+            try
+            {
+                PlatformStatus aQMConveyor = StoticCommand(conveyorLine, Stations.ChildPosiDeviceCode);
+                if (aQMConveyor.HCJ_GoodsStatus == 0)    //鍙繘琛屾斁璐�
+                {
+                    WebResponseContent webResponseContent = new WebResponseContent();
+                    //鏍规嵁绫诲瀷鏌ユ壘浠诲姟
+                    if (Stations.Station_material == (int)RGVEquipment.AbnormalOutbound)
                     {
-                        var value = conveyorLine.Communicator.Read<short>(item.DeviceProAddress);
-                        propertyInfo.SetValue(conveyorRgvCommand, value);
+                        //鏌ユ壘鏄惁鏈夊紓甯告惉杩愪换鍔�
+                        webResponseContent = _taskService.UpdateDeliveryAddress(Stations.HCJStorageaddress.ToString(), 1);   //杩橀渶瑕佷紶鍏ュ湴鍧�
+                    }
+                    else
+                    {
+                        //鍑哄簱绔欏彴鐨勪换鍔�
+                        webResponseContent = _taskService.UpdateDeliveryAddress(Stations.HCJStorageaddress.ToString(), 2);
                     }
                 }
+                return false;
             }
-            return conveyorRgvCommand;
+            catch (Exception ex)
+            {
+                return true;
+                throw;
+            }
+        }
+
+        /// <summary>
+        /// 瀹夊叏闂ㄤ俊鍙�
+        /// </summary>
+        public AQMReturnnormal AQMStoticCommand(CommonConveyorLine conveyorLine, string kladder)
+        {
+            try
+            {
+                AQMReturnnormal conveyorRgvCommand = new AQMReturnnormal();
+                List<DeviceProDTO> deviceProDTO6 = conveyorLine.DeviceProDTOs
+                    .Where(x => x.DeviceChildCode == kladder
+                                //&& DBLine.ConveyorAQMReturnnormal.Contains(x.DeviceProParamName)
+                                && x.DeviceProParamType == "ReadDeviceCommand")
+                    .ToList();
+                foreach (var item in deviceProDTO6)
+                {
+                    var paramName = item.DeviceProParamName;
+                    var propertyInfo = typeof(AQMReturnnormal).GetProperty(paramName);
+
+                    if (propertyInfo != null)
+                    {
+                        if (item.DeviceDataType == "short")
+                        {
+                            var value = conveyorLine.Communicator.Read<short>(item.DeviceProAddress);
+                            propertyInfo.SetValue(conveyorRgvCommand, value);
+                        }
+                    }
+                }
+                return conveyorRgvCommand;
+            }
+            catch (Exception ex)
+            {
+                return null;
+                throw;
+            }
         }
 
         public DeviceProDTO? GetDeviceProDTO(CommonConveyorLine conveyorLine, string PLCmanipula, string DeviceProParamName, string DeviceProParamType)
@@ -162,11 +220,13 @@
             return conveyorLine.DeviceProDTOs.FirstOrDefault(x => x.DeviceChildCode == PLCmanipula && x.DeviceProParamName == DeviceProParamName && x.DeviceProParamType == DeviceProParamType);
         }
 
+        //绔欏彴淇″彿
         public PlatformStatus StoticCommand(CommonConveyorLine conveyorLine, string kladder)
         {
             PlatformStatus conveyorRgvCommand = new PlatformStatus();
             List<DeviceProDTO> deviceProDTO6 = conveyorLine.DeviceProDTOs
                 .Where(x => x.DeviceChildCode == kladder
+                            && x.DeviceProParamName== "HCJ_GoodsStatus"
                             && x.DeviceProParamType == "ReadDeviceCommand")
                 .ToList();
             foreach (var item in deviceProDTO6)
@@ -176,7 +236,7 @@
 
                 if (propertyInfo != null)
                 {
-                    if (item.DeviceDataType == "int")
+                    if (item.DeviceDataType == "short")
                     {
                         var value = conveyorLine.Communicator.Read<short>(item.DeviceProAddress);
                         propertyInfo.SetValue(conveyorRgvCommand, value);

--
Gitblit v1.9.3