ÏîÄ¿´úÂë/WCS/WCSServices/WIDESEAWCS_Tasks/³ÉÆ·²Ö/StackerCraneJob_CP.cs
@@ -60,22 +60,26 @@
                    commonStackerCrane.CheckStackerCraneTaskCompleted();//防止任务完成事件监测超时,再手动触发一次
                    if (commonStackerCrane.StackerCraneAutoStatusValue == StackerCraneAutoStatus.Automatic && commonStackerCrane.StackerCraneStatusValue == StackerCraneStatus.Normal && commonStackerCrane.StackerCraneWorkStatusValue == StackerCraneWorkStatus.Standby)
                    {
                        Dt_Task? task = GetTask(commonStackerCrane);
                        if (task != null)
                        short stackerError = commonStackerCrane.Communicator.Read<short>("DB1000.54.0");
                        if (stackerError == 0)
                        {
                            StackerCraneTaskCommand? stackerCraneTaskCommand = ConvertToStackerCraneTaskCommand(task);
                            if (stackerCraneTaskCommand != null)
                            Dt_Task? task = GetTask(commonStackerCrane);
                            if (task != null)
                            {
                                bool sendFlag = commonStackerCrane.SendCommand(stackerCraneTaskCommand);
                                if (sendFlag)
                                StackerCraneTaskCommand? stackerCraneTaskCommand = ConvertToStackerCraneTaskCommand(task);
                                if (stackerCraneTaskCommand != null)
                                {
                                    commonStackerCrane.LastTaskType = task.TaskType;
                                    task.Dispatchertime = DateTime.Now;
                                    task.ExceptionMessage = "";
                                    _taskService.UpdateTask(task, TaskStatusEnum.SC_Executing);
                                    commonStackerCrane.Communicator.Write("DB1000.20.0", true);
                                    //延时1s
                                    Thread.Sleep(1000);
                                    bool sendFlag = commonStackerCrane.SendCommand(stackerCraneTaskCommand);
                                    if (sendFlag)
                                    {
                                        commonStackerCrane.LastTaskType = task.TaskType;
                                        task.Dispatchertime = DateTime.Now;
                                        task.ExceptionMessage = "";
                                        _taskService.UpdateTask(task, TaskStatusEnum.SC_Executing);
                                        commonStackerCrane.Communicator.Write("DB1000.20.0", true);
                                        //延时1s
                                        Thread.Sleep(1000);
                                    }
                                }
                            }
                        }
@@ -112,7 +116,7 @@
        {
            try
            {
                Dt_Task task = _taskRepository.QueryFirst(x => x.TaskNum == taskNum);
                Dt_Task task = _taskRepository.QueryFirst(x => x.TaskNum == taskNum && x.TaskState==TaskStatusEnum.SC_Executing.ObjToInt());
                if (task != null)
                {
                    if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup)
@@ -131,13 +135,14 @@
                            WriteError(deviceCode, $"未找到路由信息,{task.NextAddress}");
                            return WebResponseContent.Instance.Error($"未找到路由信息,{task.NextAddress}");
                        }
                        //堆垛机完成完成
                        int oldStatus = task.TaskState;
                        task.DeviceCode = stationManger.StationDeviceCode;
                        task.TaskState = TaskStatusEnum.Line_Execute.ObjToInt();
                        task.CurrentAddress = stationManger.StationCode;
                        task.NextAddress = router.NextPosi;
                        _taskService.UpdateTask(task, TaskStatusEnum.Line_Execute);
                        //todo å †åž›æœºå®Œæˆå®Œæˆ
                        //_taskService.UpdateTask(task, TaskStatusEnum.Line_Execute, deviceCode: stationManger.StationDeviceCode, currentAddress: stationManger.StationCode, nextAddress: router.NextPosi, targetAddress: router.NextPosi);
                        _taskExecuteDetailService.AddTaskExecuteDetail(taskNum, $"系统自动流程,任务状态从【{oldStatus}】转到【{task.TaskState}】");
                        WriteInfo(deviceCode, $"堆垛机任务完成,任务号:{taskNum}");
@@ -186,6 +191,7 @@
            {
                if (commonStackerCrane.LastTaskType.GetValueOrDefault().GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup)
                {
                    //上一个为出库则查是否存在入库任务 äº¤æ›¿æ‰§è¡Œ
                    task = _taskService.QueryStackerCraneInTask(commonStackerCrane.DeviceCode);
                    if (task == null)
                    {
@@ -194,6 +200,7 @@
                }
                else
                {
                    //上一个为入库则查是否存在出库任务 äº¤æ›¿æ‰§è¡Œ
                    task = _taskService.QueryStackerCraneOutTask(commonStackerCrane.DeviceCode);
                    if (task == null)
                    {
@@ -204,6 +211,7 @@
            if (task != null && task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup)
            {
                //判断出库站台占用
                if (OutTaskStationIsOccupied(task) == null)
                {
                    bool flag = false;
@@ -234,18 +242,24 @@
        /// <returns>如果未被占用,返回传入的任务信息,否则,返回null</returns>
        private Dt_Task? OutTaskStationIsOccupied([NotNull] Dt_Task task)
        {
            Dt_StationManger? stationManger = _stationMangerRepository.QueryFirst(x => x.StationCode == task.NextAddress && x.StackerCraneCode == task.DeviceCode);
            Dt_StationManger? stationManger = _stationMangerRepository.QueryFirst(x => (x.StationCode == task.NextAddress) && x.StackerCraneCode == task.DeviceCode);
            if (stationManger != null)
            {
                IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == stationManger.StationDeviceCode);
                if (device != null)
                {
                    OtherDevice client = (OtherDevice)device;
                    if (client.GetValue<R_ConveyorLineCPDB, short>(R_ConveyorLineCPDB.Command, stationManger.StationCode)==3)//出库站台未被占用
                    short command = client.GetValue<R_ConveyorLineCPDB, short>(R_ConveyorLineCPDB.Command, stationManger.StationCode);
                    if (command==3)//出库站台未被占用
                    {
                        task.NextAddress = stationManger.StackerCraneStationCode;
                        _taskRepository.UpdateData(task);
                        return task;
                    }
                    else
                    {
                        task.ExceptionMessage = "出库站台无法下发";
                        _taskRepository.UpdateData(task);
                    }
                }
                else
@@ -303,7 +317,7 @@
                    return null;
                }
            }
            else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup)
            else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup)//判断是否是出库任务
            {
                string[] targetCodes = task.NextAddress.Split("-");
                if (targetCodes.Length == 3)
@@ -332,7 +346,7 @@
                    return null;
                }
            }
            else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.RelocationGroup)
            else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.RelocationGroup)//判断是否是移库任务
            {
                string[] targetCodes = task.NextAddress.Split("-");
                if (targetCodes.Length == 5)