huangxiaoqiang
5 天以前 bfd2cde0cc9b9871eeab1503c837beabb9ade9e5
项目代码/WCS/WCSServices/WIDESEAWCS_Tasks/原料库/StackerCraneJob_YLSC3.cs
@@ -20,9 +20,11 @@
using WIDESEAWCS_Tasks.StackerCraneJob;
using WIDESEAWCS_Tasks;
using WIDESEAWCS_Core;
using SqlSugar.Extensions;
using WIDESEAWCS_Tasks.ConveyorLineJob;
using WIDESEAWCS_QuartzJob.Repository;
using WIDESEAWCS_Core.Helper;
using HslCommunication.WebSocket;
using WIDESEAWCS_DTO.Equipment;
namespace WIDESEAWCS_Tasks
{
@@ -36,8 +38,9 @@
        private readonly IRouterService _routerService;
        private readonly IRouterRepository _routerRepository;
        private readonly IStationMangerRepository _stationMangerRepository;
        private WebSocketServer _webSocketServer;
        public StackerCraneJob_YLSC3(ITaskService taskService, ITaskExecuteDetailService taskExecuteDetailService, ITaskRepository taskRepository, IRouterService routerService, IStationMangerRepository stationMangerRepository, IRouterRepository routerRepository)
        public StackerCraneJob_YLSC3(ITaskService taskService, ITaskExecuteDetailService taskExecuteDetailService, ITaskRepository taskRepository, IRouterService routerService, IStationMangerRepository stationMangerRepository, IRouterRepository routerRepository,WebSocketServer webSocketServer)
        {
            _taskService = taskService;
            _taskExecuteDetailService = taskExecuteDetailService;
@@ -45,6 +48,7 @@
            _routerService = routerService;
            _stationMangerRepository = stationMangerRepository;
            _routerRepository = routerRepository;
            _webSocketServer = webSocketServer;
        }
        public Task Execute(IJobExecutionContext context)
@@ -76,8 +80,7 @@
                                        commonStackerCrane.LastTaskType = task.TaskType;
                                        task.Dispatchertime = DateTime.Now;
                                        task.ExceptionMessage = "";
                                        _taskService.UpdateTask(task, TaskStatusEnum.SC_Executing);
                                        //_taskService.UpdateTaskStatusToNext(task);
                                        _taskService.UpdateTaskStatusToNext(task);
                                        commonStackerCrane.Communicator.Write("DB1000.20.0", true);
                                        //寤舵椂1s
                                        Thread.Sleep(1000);
@@ -86,6 +89,25 @@
                            }
                        }
                    }
                    #region 璋冪敤浜嬩欢鎬荤嚎閫氱煡鍓嶇
                    EquipmentDTO equipmentDTO = new EquipmentDTO();
                    object obj = new
                    {
                        commonStackerCrane.DeviceName,
                        commonStackerCrane.DeviceCode,
                        StackerCraneAutoStatus.Automatic,
                        StackerCraneStatus.Normal,
                        StackerCraneWorkStatus.Standby,
                        TaskNum = commonStackerCrane.CurrentTaskNum,
                        WorkType = commonStackerCrane.GetValue<StackerCraneDBName, short>(StackerCraneDBName.WorkType),
                        StackerAlarm = commonStackerCrane.Communicator.Read<short>("DB1000.54.0"),
                    };
                    equipmentDTO.StackerDataJson = obj.Serialize();
                    _webSocketServer.PublishAllClientPayload(equipmentDTO.Serialize());
                    #endregion
                }
            }
            catch (Exception ex)
@@ -153,6 +175,7 @@
                                conveyorLine.SetValue(ConveyorLineDBName.TaskNum, taskNum, stationManger.StationCode);
                                conveyorLine.SetValue(ConveyorLineDBName.TargetAddress, router.NextPosi, stationManger.StationCode);
                                conveyorLine.SetValue(ConveyorLineDBName.Width, task.TaskLength, stationManger.StationCode);
                                conveyorLine.SetValue(ConveyorLineDBName.Height, task.HeightType, stationManger.StationCode);
                                conveyorLine.SetValue(ConveyorLineDBName.Barcode, task.PalletCode, stationManger.StationCode);
                                conveyorLine.SetValue(ConveyorLineDBName.ResponState, 86, stationManger.StationCode);
                                _taskService.UpdateTaskStatusToNext(task);
@@ -364,9 +387,9 @@
                string[] targetCodes = task.NextAddress.Split("-");
                if (targetCodes.Length == 3)
                {
                    stackerCraneTaskCommand.EndRow = Convert.ToInt16(targetCodes[1]);
                    stackerCraneTaskCommand.EndColumn = Convert.ToInt16(targetCodes[2]);
                    stackerCraneTaskCommand.EndLayer = Convert.ToInt16(targetCodes[3]);
                    stackerCraneTaskCommand.EndRow = Convert.ToInt16(targetCodes[0]);
                    stackerCraneTaskCommand.EndColumn = Convert.ToInt16(targetCodes[1]);
                    stackerCraneTaskCommand.EndLayer = Convert.ToInt16(targetCodes[2]);
                }
                else
                {
@@ -377,9 +400,9 @@
                string[] sourceCodes = task.CurrentAddress.Split("-");
                if (sourceCodes.Length == 5)
                {
                    stackerCraneTaskCommand.StartRow = Convert.ToInt16(sourceCodes[0]);
                    stackerCraneTaskCommand.StartColumn = Convert.ToInt16(sourceCodes[1]);
                    stackerCraneTaskCommand.StartLayer = Convert.ToInt16(sourceCodes[2]);
                    stackerCraneTaskCommand.StartRow = Convert.ToInt16(sourceCodes[1]);
                    stackerCraneTaskCommand.StartColumn = Convert.ToInt16(sourceCodes[2]);
                    stackerCraneTaskCommand.StartLayer = Convert.ToInt16(sourceCodes[3]);
                }
                else
                {