HuBingJie
10 天以前 21078521d79f0eb5535cc34be7917a3fd1123b8f
´úÂë¹ÜÀí/WCS/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/CommonConveyorLineJob.cs
@@ -30,14 +30,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)
@@ -48,55 +52,105 @@
                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)
                            //获取到安全门信息
                            AQMReturnnormal aQMConveyor = AQMStoticCommand(conveyorLine, Stations.ChildPosiDeviceCode);
                            if(Stations.Station_tasktype== (int)RGVTasktype.Outbound)
                            {
                                //查找是否有异常搬运任务
                                webResponseContent = _taskService.UpdateDeliveryAddress(Stations.HCJStorageaddress.ToString(), 1);   //还需要传入地址
                                //读取堆垛机与RGV是否在报警,如果在报警,则写入安全门报警
                                if (_gvOperationService.AQMReadAlarminform(2) && _equipmentStatusService.GetSCstatus())
                                {
                                    //写入报警
                                    GetDeviceAddress.WriteSecurityDoorpolice(Stations.ChildPosiDeviceCode, "AlarmSummary", 1);
                                }
                                //安全门急停状态
                                if (aQMConveyor.EmergencyStopStatus == 0)
                                {
                                    //立马停止全部RGV(得判断RGV状态,没停止的则停止)
                                    _gvOperationService.WriteOutbuttonpause(null);
                                }
                                //安全门进行请求
                                if (aQMConveyor.DoorRequest == 1 && aQMConveyor.IndicatorStatus== (int)SafetyDoorStatus.YellowBlink2Hz)
                                {
                                    //读取到请求后,根据状态指示灯进行操作
                                    if (aQMConveyor.EmergencyStopStatus == 1 && aQMConveyor.EmergencyStopStatus == 0)   //未急停,需要申请进入设备
                                    {
                                        //直接停止RGV动作
                                        _gvOperationService.WriteOutbuttonpause(null);
                                        //读取子母车是否都在空闲状态
                                        if (GetDeviceAddress.OutRGVStatice())   //读取子母车状态
                                        {
                                            //写入开门信号
                                            GetDeviceAddress.WriteSecurityDoorpolice(Stations.ChildPosiDeviceCode, "OpenDoor", 1);
                                        }
                                    }
                                }
                            }
                            else
                            {
                                //出库站台的任务
                                webResponseContent = _taskService.UpdateDeliveryAddress(Stations.HCJStorageaddress.ToString(), 2);
                                if (_gvOperationService.AQMReadAlarminform(1) && _equipmentStatusService.GetSCstatus())
                                {
                                    //写入报警
                                    GetDeviceAddress.WriteSecurityDoorpolice(Stations.ChildPosiDeviceCode, "AlarmSummary", 1);
                                }
                                //安全门急停状态
                                if (aQMConveyor.EmergencyStopStatus == 0)
                                {
                                    //立马停止全部RGV(得判断RGV状态,没停止的则停止)
                                    _gvOperationService.InWriteOutbuttonpause(null);
                                }
                                //安全门进行请求
                                if (aQMConveyor.DoorRequest == 1 && aQMConveyor.IndicatorStatus == (int)SafetyDoorStatus.YellowBlink2Hz)
                                {
                                    //读取到请求后,根据状态指示灯进行操作
                                    if (aQMConveyor.EmergencyStopStatus == 1 && aQMConveyor.EmergencyStopStatus == 0)   //未急停,需要申请进入设备
                                    {
                                        //直接停止RGV动作
                                        _gvOperationService.InWriteOutbuttonpause(null);
                                        //读取子母车是否都在空闲状态
                                        if (GetDeviceAddress.OutRGVStatice())   //读取子母车状态
                                        {
                                            //写入开门信号
                                            GetDeviceAddress.WriteSecurityDoorpolice(Stations.ChildPosiDeviceCode, "OpenDoor", 1);
                                        }
                                    }
                                }
                            }
                        }
                    }*/
                    /*
                    //安全门开门申请+安全门状态  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)
                            PlatformStatus aQMConveyor = StoticCommand(conveyorLine, Stations.ChildPosiDeviceCode);
                            if (aQMConveyor.HCJ_GoodsStatus == 0)    //可进行放货
                            {
                                //需要判断rgv,堆垛机是否允许开门
                                //如果允许开门,则写入4,表示切换成功,
                                bool Maintenancebool = conveyorLine.Communicator.Write(deviceProDtqh.DeviceProDataBlock, (short)4);
                                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);
                                }
                            }
                        }
                        }*/
                    }
                    else
                    {
                        //读取DBW8=1,DBW6=1,DBW10=1,DBW4=1,符合后,进行写入切换状态DBW0=3
                        AQMReturnnormal aQMReturnnormal=AQMStoticCommand(conveyorLine, "AQM001");   //判断
                    }*/
                }
            }
            catch (Exception ex)
@@ -132,29 +186,40 @@
            return conveyorRgvCommand;
        }
        /// <summary>
        /// å®‰å…¨é—¨ä¿¡å·
        /// </summary>
        public AQMReturnnormal AQMStoticCommand(CommonConveyorLine conveyorLine, string kladder)
        {
            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);
                if (propertyInfo != null)
                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)
                {
                    if (item.DeviceDataType == "int")
                    var paramName = item.DeviceProParamName;
                    var propertyInfo = typeof(AQMReturnnormal).GetProperty(paramName);
                    if (propertyInfo != null)
                    {
                        var value = conveyorLine.Communicator.Read<short>(item.DeviceProAddress);
                        propertyInfo.SetValue(conveyorRgvCommand, value);
                        if (item.DeviceDataType == "short")
                        {
                            var value = conveyorLine.Communicator.Read<short>(item.DeviceProAddress);
                            propertyInfo.SetValue(conveyorRgvCommand, value);
                        }
                    }
                }
                return conveyorRgvCommand;
            }
            return conveyorRgvCommand;
            catch (Exception ex)
            {
                return null;
                throw;
            }
        }
        public DeviceProDTO? GetDeviceProDTO(CommonConveyorLine conveyorLine, string PLCmanipula, string DeviceProParamName, string DeviceProParamType)