liulijun
21 小时以前 5270308151082506e0e6df2c72d278d2976ec860
ÏîÄ¿´úÂë/WCS/WCSServices/WIDESEAWCS_Tasks/Ô­ÁÏ¿â/StackerCraneJob_YLSC3.cs
@@ -1,4 +1,6 @@
using Microsoft.AspNetCore.Components.Routing;
using HslCommunication.WebSocket;
using Microsoft.AspNetCore.Components.Routing;
using Newtonsoft.Json;
using Quartz;
using System;
using System.Collections.Generic;
@@ -7,7 +9,10 @@
using System.Text;
using System.Threading.Tasks;
using WIDESEAWCS_Common.TaskEnum;
using WIDESEAWCS_Core;
using WIDESEAWCS_Core.Enums;
using WIDESEAWCS_Core.Helper;
using WIDESEAWCS_DTO.Equipment;
using WIDESEAWCS_IBasicInfoRepository;
using WIDESEAWCS_ITaskInfoRepository;
using WIDESEAWCS_ITaskInfoService;
@@ -15,17 +20,20 @@
using WIDESEAWCS_QuartzJob;
using WIDESEAWCS_QuartzJob.DeviceBase;
using WIDESEAWCS_QuartzJob.Models;
using WIDESEAWCS_QuartzJob.Repository;
using WIDESEAWCS_QuartzJob.Service;
using WIDESEAWCS_QuartzJob.StackerCrane;
using WIDESEAWCS_QuartzJob.StackerCrane.Enum;
using WIDESEAWCS_Tasks.StackerCraneJob;
using WIDESEAWCS_Tasks;
using WIDESEAWCS_Core;
using WIDESEAWCS_Tasks.ConveyorLineJob;
using WIDESEAWCS_QuartzJob.Repository;
using WIDESEAWCS_Core.Helper;
using HslCommunication.WebSocket;
using WIDESEAWCS_DTO.Equipment;
using WIDESEAWCS_QuartzJob.StackerCrane;
using WIDESEAWCS_Tasks.StackerCraneJob;
using WIDESEAWCS_DTO.TaskInfo;
using WIDESEAWCS_Tasks.原料库;
namespace WIDESEAWCS_Tasks
{
@@ -39,7 +47,7 @@
        private readonly IRouterService _routerService;
        private readonly IRouterRepository _routerRepository;
        private readonly IStationMangerRepository _stationMangerRepository;
        private WebSocketServer _webSocketServer;
        private readonly WebSocketServer _webSocketServer;
        public StackerCraneJob_YLSC3(ITaskService taskService, ITaskExecuteDetailService taskExecuteDetailService, ITaskRepository taskRepository, IRouterService routerService, IStationMangerRepository stationMangerRepository, IRouterRepository routerRepository,WebSocketServer webSocketServer)
        {
@@ -66,7 +74,7 @@
                    commonStackerCrane.CheckStackerCraneTaskCompleted();//防止任务完成事件监测超时,再手动触发一次
                    //获取当前堆垛机状态
                    if (commonStackerCrane.CurrentTaskNum>0 && commonStackerCrane.StackerCraneWorkStatusValue == StackerCraneWorkStatus.WorkCompleted)
                    if (commonStackerCrane.CurrentTaskNum>0 && (commonStackerCrane.StackerCraneWorkStatusValue == StackerCraneWorkStatus.WorkCompleted || commonStackerCrane.Communicator.Read<short>("DB1000.40.0") == 3))
                    {
                        StackerCraneTaskCompletedEventArgs e = new StackerCraneTaskCompletedEventArgs(commonStackerCrane.CurrentTaskNum);
                        CommonStackerCrane_StackerCraneTaskCompletedEventHandler(commonStackerCrane, e);
@@ -95,8 +103,59 @@
                                    }
                                }
                            }
                            ErrorDeviceInfo? deviceInfo = RoadwayError.Roadways.FirstOrDefault(x => x.Code == commonStackerCrane.DeviceCode);
                            if (deviceInfo != null)
                            {
                                RoadwayError.Roadways.Remove(deviceInfo);
                            }
                        }
                        else
                        {
                            ErrorDeviceInfo? deviceInfo = RoadwayError.Roadways.FirstOrDefault(x => x.Code == commonStackerCrane.DeviceCode);
                            if (deviceInfo == null)
                            {
                                RoadwayError.Roadways.Add(new ErrorDeviceInfo() { Code = commonStackerCrane.DeviceCode, Roadway = commonStackerCrane.DeviceCode });
                            }
                        }
                    }
                    // è®¾ç½®è®¾å¤‡ç¼–号,前端用于识别堆垛机
                    YL_DB yL_DB = new YL_DB();
                    yL_DB.R_PP_Status = commonStackerCrane.DeviceCode;
                    // è®¾ç½®å †åž›æœºçŠ¶æ€
                    yL_DB.YL_Status = commonStackerCrane.StackerCraneStatusValue switch
                    {
                        StackerCraneStatus.Fault => 0,
                        StackerCraneStatus.Normal => 1,
                        StackerCraneStatus.EmergencyStop => 2,
                        StackerCraneStatus.Unkonw => 3,
                    };
                    yL_DB.YL_AutoStatus = commonStackerCrane.StackerCraneAutoStatusValue switch
                    {
                        StackerCraneAutoStatus.SemiAutomatic => 1,
                        StackerCraneAutoStatus.Maintenance => 2,
                        StackerCraneAutoStatus.Automatic => 3,
                        StackerCraneAutoStatus.Manual => 4,
                        StackerCraneAutoStatus.Unkonw => 5,
                    };
                    yL_DB.YL_WorkStatus = commonStackerCrane.StackerCraneWorkStatusValue switch
                    {
                        StackerCraneWorkStatus.Standby => 1,
                        StackerCraneWorkStatus.PickUpCompleted => 2,
                        StackerCraneWorkStatus.PickUp => 3,
                        StackerCraneWorkStatus.Putting => 5,
                        StackerCraneWorkStatus.WorkCompleted => 9,
                    };
                    yL_DB.YL_TaskNum = commonStackerCrane.CurrentTaskNum;
                    yL_DB.YL_WorkType = commonStackerCrane.GetValue<StackerCraneDBName, short>(StackerCraneDBName.WorkType);
                    yL_DB.YL_Row = commonStackerCrane.Communicator.Read<short>("DB1000.46");
                    yL_DB.YL_Column = commonStackerCrane.Communicator.Read<short>("DB1000.48.0");
                    yL_DB.YL_Layer = commonStackerCrane.Communicator.Read<short>("DB1000.50.0");
                    // è¯»å–报警信息
                    short stackerError2 = commonStackerCrane.Communicator.Read<short>("DB1000.54.0");
                    yL_DB.StackerAlarm = stackerError2 == 0 ? "无" : $"报警代码: {stackerError2}";
                    // åºåˆ—化并发送数据
                    string ylDB = JsonConvert.SerializeObject(yL_DB);
                    _webSocketServer.PublishAllClientPayload(ylDB);
                    #region è°ƒç”¨äº‹ä»¶æ€»çº¿é€šçŸ¥å‰ç«¯
@@ -266,7 +325,7 @@
            Dt_Task? task;
            if (commonStackerCrane.LastTaskType == null)
            {
                task = _taskService.QueryStackerCraneTask(commonStackerCrane.DeviceCode);
                task = _taskService.QueryStackerYLTask(commonStackerCrane.DeviceCode);
            }
            else
            {
@@ -276,13 +335,13 @@
                    task = _taskService.QueryStackerCraneInTask(commonStackerCrane.DeviceCode);
                    if (task == null)
                    {
                        task = _taskService.QueryStackerCraneOutTask(commonStackerCrane.DeviceCode);
                        task = _taskService.QueryStackerYLTask(commonStackerCrane.DeviceCode, TaskTypeGroup.OutbondGroup);
                    }
                }
                else
                {
                    //上一个为入库则查是否存在出库任务 äº¤æ›¿æ‰§è¡Œ
                    task = _taskService.QueryStackerCraneOutTask(commonStackerCrane.DeviceCode);
                    task = _taskService.QueryStackerYLTask(commonStackerCrane.DeviceCode, TaskTypeGroup.OutbondGroup);
                    if (task == null)
                    {
                        task = _taskService.QueryStackerCraneInTask(commonStackerCrane.DeviceCode);
@@ -346,6 +405,7 @@
                        {
                            task.ExceptionMessage = "出库站台无法下发";
                            _taskRepository.UpdateData(task);
                            WriteInfo(task.DeviceCode, $"出库站台无法下发");
                        }
                    }
                    else
@@ -362,8 +422,8 @@
                        CommonConveyorLine client = (CommonConveyorLine)device;
                        if (client.GetValue<ConveyorLineDBName, short>(ConveyorLineDBName.InteractiveSignal, stationManger.StationCode) != 99)//出库站台未被占用
                        {
                            task.NextAddress = stationManger.StackerCraneStationCode;
                            _taskRepository.UpdateData(task);
                            //task.NextAddress = stationManger.StackerCraneStationCode;
                            //_taskRepository.UpdateData(task);
                            return task;
                        }
                        else
@@ -398,6 +458,10 @@
            YLStackerCraneTaskCommand stackerCraneTaskCommand = new YLStackerCraneTaskCommand();
            stackerCraneTaskCommand.PalletType = Convert.ToInt16(task.PalletType);
            if (task.TaskLength>=1200 && task.TaskLength<1630)
            {
                stackerCraneTaskCommand.PalletType = 3;
            }
            stackerCraneTaskCommand.TaskNum = task.TaskNum;
            stackerCraneTaskCommand.WorkType = 5;
            if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.InboundGroup)//判断是否是入库任务