1
huangxiaoqiang
6 天以前 42a51b0fc2041b872691637db0ec01391a67e026
ÏîÄ¿´úÂë/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/RGVJob_FirstFloor/CommonRGV_FirstFloorJob.cs
@@ -433,7 +433,6 @@
                    {
                        if (commonRGVSecond.GetValue<RGVDBName, bool>(RGVDBName.Automatic) && !commonRGVSecond.GetValue<RGVDBName, bool>(RGVDBName.Fault))
                        {
                            var taskSecond = _taskRepository.QueryFirst(x => x.RGVName == "RGV02" && x.TaskNum == commonRGVSecond.GetValue<RGVDBName, short>(RGVDBName.RGVTaskNum) && ((x.TaskType == (int)TaskInboundTypeEnum.Inbound && (x.TaskState < 230||x.TaskState == (int)TaskInStatusEnum.RGV_TransFer|| x.TaskState == (int)TaskInStatusEnum.RGV_TransFerFInish)) || (x.TaskType == (int)TaskOutboundTypeEnum.Outbound)));
                            if (taskSecond != null)
                            {
@@ -449,7 +448,26 @@
                                            if (task.Remark != null)
                                            {
                                                return GetDispatchExecutingTask(task);
                                                return GetDispatchExecutingTask(task, taskSecond);
                                            }
                                            return task;
                                        }
                                    }
                                }
                                else if ((taskSecond.CurrentAddress == "1025" || taskSecond.CurrentAddress == "1026") && (taskSecond.TaskState == (int)TaskOutStatusEnum.RGV_OutExecuting || taskSecond.TaskState == (int)TaskInStatusEnum.RGV_InExecuting))
                                {
                                    if (task.TaskState == (int)TaskOutStatusEnum.RGV_OutdispatchFinish || task.TaskState == (int)TaskInStatusEnum.RGV_IndispatchFinish)
                                    {
                                        if (task.TargetStation - taskSecond.SourceStation > 1 && task.TargetStation - taskSecond.TargetStation > 1)
                                        {
                                            LogAndWarn("执行调度任务控制", $"【{commonRGV.DeviceCode}工作模式:【{commonRGV.GetValue<RGVDBName, bool>(RGVDBName.Automatic)}】设备状态:【{commonRGVSecond.GetValue<RGVDBName, bool>(RGVDBName.Fault)}】【{commonRGVSecond.DeviceCode}】任务【{JsonConvert.SerializeObject(taskSecond)}】{commonRGVSecond.DeviceCode}返回任务:【{JsonConvert.SerializeObject(task.TaskNum)}】】");
                                            Thread.Sleep(1000);
                                            if (task.Remark != null)
                                            {
                                                return GetDispatchExecutingTask(task, taskSecond);
                                            }
                                            return task;
@@ -466,7 +484,7 @@
                                            Thread.Sleep(1000);
                                            if (task.Remark != null)
                                            {
                                                return GetDispatchExecutingTask(task);
                                                return GetDispatchExecutingTask(task, taskSecond);
                                            }
                                            return task;
                                        }
@@ -482,6 +500,10 @@
                                }
                                if (commonRGVSecond.GetValue<RGVDBName, int>(RGVDBName.LevelPoint) > 35000)
                                {
                                    if (commonRGVSecond.GetValue<RGVDBName, bool>(RGVDBName.Running))
                                    {
                                        return null;
                                    }
                                    RGVTaskCommand command = new RGVTaskCommand()
                                    {
                                        PickupLocation = (byte)Convert.ToSByte(15),
@@ -523,7 +545,24 @@
                                            if (task.Remark != null)
                                            {
                                                return GetDispatchExecutingTask(task);
                                                return GetDispatchExecutingTask(task, taskSecond);
                                            }
                                            return task;
                                        }
                                    }
                                }
                                else if ((taskSecond.CurrentAddress == "1025" || taskSecond.CurrentAddress == "1026") && (taskSecond.TaskState == (int)TaskOutStatusEnum.RGV_OutExecuting || taskSecond.TaskState == (int)TaskInStatusEnum.RGV_InExecuting))
                                {
                                    if (task.TaskState == (int)TaskOutStatusEnum.RGV_OutdispatchFinish || task.TaskState == (int)TaskInStatusEnum.RGV_IndispatchFinish)
                                    {
                                        if (taskSecond.SourceStation - task.TargetStation > 1 && taskSecond.TargetStation - task.TargetStation > 1)
                                        {
                                            LogAndWarn("执行调度任务控制", $"【{commonRGV.DeviceCode}工作模式:【{commonRGV.GetValue<RGVDBName, bool>(RGVDBName.Automatic)}】设备状态:【{commonRGVFirst.GetValue<RGVDBName, bool>(RGVDBName.Fault)}】【{commonRGVFirst.DeviceCode}】任务【{JsonConvert.SerializeObject(taskSecond)}】{commonRGVFirst.DeviceCode}返回任务:【{JsonConvert.SerializeObject(task.TaskNum)}】】");
                                            Thread.Sleep(1000);
                                            if (task.Remark != null)
                                            {
                                                return GetDispatchExecutingTask(task, taskSecond);
                                            }
                                            return task;
                                        }
@@ -540,7 +579,7 @@
                                            if (task.Remark != null)
                                            {
                                                return GetDispatchExecutingTask(task);
                                                return GetDispatchExecutingTask(task, taskSecond);
                                            }
                                            return task;
                                        }
@@ -556,6 +595,10 @@
                                }
                                if (commonRGVFirst.GetValue<RGVDBName, int>(RGVDBName.LevelPoint) < 420000)
                                {
                                    if (commonRGVFirst.GetValue<RGVDBName, bool>(RGVDBName.Running))
                                    {
                                        return null;
                                    }
                                    RGVTaskCommand command = new RGVTaskCommand()
                                    {
                                        PickupLocation = (byte)Convert.ToSByte(26),
@@ -623,6 +666,10 @@
                        }
                        if (commonRGVSecond.GetValue<RGVDBName, int>(RGVDBName.LevelPoint) > 35000)
                        {
                            if (commonRGVSecond.GetValue<RGVDBName, bool>(RGVDBName.Running))
                            {
                                return null;
                            }
                            RGVTaskCommand command = new RGVTaskCommand()
                            {
                                PickupLocation = (byte)Convert.ToSByte(15),
@@ -679,7 +726,7 @@
                            {
                                task = GetDispatchTask(tasks, taskFirst);
                                LogAndWarn("执行调度任务控制", $"【{commonRGVFirst.DeviceCode}工作模式:【{commonRGVFirst.GetValue<RGVDBName, bool>(RGVDBName.Automatic)}】设备状态:【{commonRGVFirst.GetValue<RGVDBName, bool>(RGVDBName.Fault)}】【{commonRGVFirst.DeviceCode}】任务【{JsonConvert.SerializeObject(taskFirst)}】{commonRGVFirst.DeviceCode}返回任务:【{JsonConvert.SerializeObject(task.TaskNum)}】】");
                                LogAndWarn("调度任务控制", $"【{commonRGVFirst.DeviceCode}工作模式:【{commonRGVFirst.GetValue<RGVDBName, bool>(RGVDBName.Automatic)}】设备状态:【{commonRGVFirst.GetValue<RGVDBName, bool>(RGVDBName.Fault)}】【{commonRGVFirst.DeviceCode}】任务【{JsonConvert.SerializeObject(taskFirst)}】{commonRGVFirst.DeviceCode}返回任务:【{JsonConvert.SerializeObject(task.TaskNum)}】】");
                                Thread.Sleep(1000);
                                return task;
@@ -696,6 +743,10 @@
                        }
                        if (commonRGVFirst.GetValue<RGVDBName, int>(RGVDBName.LevelPoint) < 420000)
                        {
                            if (commonRGVFirst.GetValue<RGVDBName, bool>(RGVDBName.Running))
                            {
                                return null;
                            }
                            RGVTaskCommand command = new RGVTaskCommand()
                            {
                                PickupLocation = (byte)Convert.ToSByte(26),
@@ -799,6 +850,10 @@
                                }
                                if (commonRGVSecond.GetValue<RGVDBName, int>(RGVDBName.LevelPoint) > 35000)
                                {
                                    if (commonRGVSecond.GetValue<RGVDBName, bool>(RGVDBName.Running))
                                    {
                                        return null;
                                    }
                                    RGVTaskCommand command = new RGVTaskCommand()
                                    {
                                        PickupLocation = (byte)Convert.ToSByte(15),
@@ -856,7 +911,7 @@
                                if (taskFirst.TaskState == (int)TaskOutStatusEnum.RGV_Outdispatch || taskFirst.TaskState == (int)TaskOutStatusEnum.RGV_OutdispatchFinish || taskFirst.TaskState == (int)TaskInStatusEnum.RGV_IndispatchFinish)
                                {
                                    task = tasks.FirstOrDefault(x => ((x.SourceStation - taskFirst.TargetStation > 1 && x.SourceStation - taskFirst.SourceStation > 1 && x.TaskType == (int)TaskInboundTypeEnum.Inbound) || (x.SourceStation - taskFirst.TargetStation > 1 && x.TargetStation - taskFirst.SourceStation > 1 && x.SourceStation - taskFirst.SourceStation > 1 && x.TargetStation - taskFirst.TargetStation > 1 && x.TaskType == (int)TaskOutboundTypeEnum.Outbound)) && x.RGVName == "RGV02");
                                    task = tasks.FirstOrDefault(x => ((taskFirst.TargetStation-x.SourceStation  > 1 &&taskFirst.SourceStation - x.SourceStation > 1 && x.TaskType == (int)TaskInboundTypeEnum.Inbound) || ( taskFirst.TargetStation- x.SourceStation > 1 &&  taskFirst.SourceStation- x.TargetStation > 1 &&  taskFirst.SourceStation- x.SourceStation > 1 && taskFirst.TargetStation - x.TargetStation > 1 && x.TaskType == (int)TaskOutboundTypeEnum.Outbound)) && x.RGVName == "RGV02");
                                    LogAndWarn("中转调度任务控制", $"【{commonRGVFirst.DeviceCode}工作模式:【{commonRGVFirst.GetValue<RGVDBName, bool>(RGVDBName.Automatic)}】设备状态:【{commonRGVFirst.GetValue<RGVDBName, bool>(RGVDBName.Fault)}】【{commonRGVFirst.DeviceCode}】任务【{JsonConvert.SerializeObject(taskFirst)}】{commonRGVFirst.DeviceCode}返回任务:【{JsonConvert.SerializeObject(task.TaskNum)}】】");
@@ -882,6 +937,10 @@
                                }
                                if (commonRGVFirst.GetValue<RGVDBName, int>(RGVDBName.LevelPoint) < 420000)
                                {
                                    if (commonRGVFirst.GetValue<RGVDBName, bool>(RGVDBName.Running))
                                    {
                                        return null;
                                    }
                                    RGVTaskCommand command = new RGVTaskCommand()
                                    {
                                        PickupLocation = (byte)Convert.ToSByte(26),
@@ -1034,19 +1093,44 @@
            Dt_Task y = tasks.Where(x => x.Remark != null&& ((x.SourceStation - oldtask.TargetStation > 1 && x.SourceStation - oldtask.SourceStation > 1 && x.TaskType == (int)TaskInboundTypeEnum.Inbound) || (x.SourceStation - oldtask.TargetStation > 1 && x.TargetStation - oldtask.SourceStation > 1 && x.SourceStation - oldtask.SourceStation > 1 && x.TargetStation - oldtask.TargetStation > 1 && x.TaskType == (int)TaskOutboundTypeEnum.Outbound))).FirstOrDefault();
            if (y == null)
            {
                LogAndWarn("查询任务", $" è¿”回任务:【{JsonConvert.SerializeObject(oldtask)}】】");
                WriteInfo("查询任务", $" è¿”回任务:【{JsonConvert.SerializeObject(oldtask)}】】");
                if (oldtask.TaskState == (int)TaskOutStatusEnum.RGV_Outdispatch || oldtask.TaskState == (int)TaskOutStatusEnum.RGV_OutdispatchFinish || oldtask.TaskState == (int)TaskInStatusEnum.RGV_IndispatchFinish)
                {
                    return tasks.FirstOrDefault(x => (x.SourceStation - oldtask.TargetStation > 1 && x.SourceStation - oldtask.SourceStation > 1 && x.TaskType == (int)TaskInboundTypeEnum.Inbound) || (x.SourceStation - oldtask.TargetStation > 1 && x.TargetStation - oldtask.SourceStation > 1 && x.SourceStation - oldtask.SourceStation > 1 && x.TargetStation - oldtask.TargetStation > 1 && x.TaskType == (int)TaskOutboundTypeEnum.Outbound));
                    if (oldtask.RGVName == "RGV01")
                    {
                        return tasks.FirstOrDefault(x => (oldtask.TargetStation - x.SourceStation > 1 && oldtask.SourceStation - x.SourceStation > 1 && x.TaskType == (int)TaskInboundTypeEnum.Inbound) || (oldtask.TargetStation - x.SourceStation > 1 && oldtask.SourceStation - x.TargetStation > 1 && oldtask.SourceStation - x.SourceStation > 1 && oldtask.TargetStation - x.TargetStation > 1 && x.TaskType == (int)TaskOutboundTypeEnum.Outbound));
                    }
                    else
                    {
                        return tasks.FirstOrDefault(x => (x.SourceStation - oldtask.TargetStation > 1 && x.SourceStation - oldtask.SourceStation > 1 && x.TaskType == (int)TaskInboundTypeEnum.Inbound) || (x.SourceStation - oldtask.TargetStation > 1 && x.TargetStation - oldtask.SourceStation > 1 && x.SourceStation - oldtask.SourceStation > 1 && x.TargetStation - oldtask.TargetStation > 1 && x.TaskType == (int)TaskOutboundTypeEnum.Outbound));
                    }
                }
                else if ((oldtask.CurrentAddress == "1025" || oldtask.CurrentAddress == "1026") && (oldtask.TaskState == (int)TaskOutStatusEnum.RGV_OutExecuting || oldtask.TaskState == (int)TaskInStatusEnum.RGV_InExecuting))
                {
                    return tasks.FirstOrDefault(x => (x.SourceStation - oldtask.TargetStation > 1 && x.SourceStation - oldtask.SourceStation > 1 && x.TaskType == (int)TaskInboundTypeEnum.Inbound) || (x.SourceStation - oldtask.TargetStation > 1 && x.TargetStation - oldtask.SourceStation > 1 && x.SourceStation - oldtask.SourceStation > 1 && x.TargetStation - oldtask.TargetStation > 1 && x.TaskType == (int)TaskOutboundTypeEnum.Outbound));
                    if (oldtask.RGVName == "RGV01")
                    {
                        return tasks.FirstOrDefault(x => (oldtask.TargetStation - x.SourceStation > 1 && oldtask.SourceStation - x.SourceStation > 1 && x.TaskType == (int)TaskInboundTypeEnum.Inbound) || (oldtask.TargetStation - x.SourceStation > 1 && oldtask.SourceStation - x.TargetStation > 1 && oldtask.SourceStation - x.SourceStation > 1 && oldtask.TargetStation - x.TargetStation > 1 && x.TaskType == (int)TaskOutboundTypeEnum.Outbound));
                    }
                    else
                    {
                        return tasks.FirstOrDefault(x => (x.SourceStation - oldtask.TargetStation > 1 && x.SourceStation - oldtask.SourceStation > 1 && x.TaskType == (int)TaskInboundTypeEnum.Inbound) || (x.SourceStation - oldtask.TargetStation > 1 && x.TargetStation - oldtask.SourceStation > 1 && x.SourceStation - oldtask.SourceStation > 1 && x.TargetStation - oldtask.TargetStation > 1 && x.TaskType == (int)TaskOutboundTypeEnum.Outbound));
                    }
                }
                else if (oldtask.TaskState == (int)TaskOutStatusEnum.RGV_OutExecuting || oldtask.TaskState == (int)TaskInStatusEnum.RGV_InExecuting)
                {
                    return tasks.FirstOrDefault(x => x.SourceStation - oldtask.TargetStation > 1 && x.TargetStation - oldtask.TargetStation > 1);
                    if (oldtask.RGVName == "RGV01")
                    {
                        return tasks.FirstOrDefault(x => oldtask.TargetStation - x.SourceStation > 1 && oldtask.TargetStation - x.TargetStation > 1);
                    }
                    else
                    {
                        return tasks.FirstOrDefault(x => x.SourceStation - oldtask.TargetStation > 1 && x.TargetStation - oldtask.TargetStation > 1);
                    }
                }
                
                return null;
@@ -1079,6 +1163,10 @@
                    return tasks.FirstOrDefault(x => (x.SourceStation - oldtask.TargetStation > 1 && x.SourceStation - oldtask.SourceStation > 1 && x.TaskType == (int)TaskInboundTypeEnum.Inbound) || (x.SourceStation - oldtask.TargetStation > 1 && x.TargetStation - oldtask.SourceStation > 1 && x.SourceStation - oldtask.SourceStation > 1 && x.TargetStation - oldtask.TargetStation > 1 && x.TaskType == (int)TaskOutboundTypeEnum.Outbound));
                }
                else if ((oldtask.CurrentAddress == "1025" || oldtask.CurrentAddress == "1026") && (oldtask.TaskState == (int)TaskOutStatusEnum.RGV_OutExecuting || oldtask.TaskState == (int)TaskInStatusEnum.RGV_InExecuting))
                {
                    return tasks.FirstOrDefault(x => (x.SourceStation - oldtask.TargetStation > 1 && x.SourceStation - oldtask.SourceStation > 1 && x.TaskType == (int)TaskInboundTypeEnum.Inbound) || (x.SourceStation - oldtask.TargetStation > 1 && x.TargetStation - oldtask.SourceStation > 1 && x.SourceStation - oldtask.SourceStation > 1 && x.TargetStation - oldtask.TargetStation > 1 && x.TaskType == (int)TaskOutboundTypeEnum.Outbound));
                }
                else if (oldtask.TaskState == (int)TaskOutStatusEnum.RGV_OutExecuting || oldtask.TaskState == (int)TaskInStatusEnum.RGV_InExecuting)
                {
                    return tasks.FirstOrDefault(x => x.SourceStation - oldtask.TargetStation > 1 && x.TargetStation - oldtask.TargetStation > 1);
@@ -1087,13 +1175,13 @@
            }
        }
        public Dt_Task? GetDispatchExecutingTask(Dt_Task oldtask)
        public Dt_Task? GetDispatchExecutingTask(Dt_Task oldtask,Dt_Task task)
        {
            var stationManager = _stationManagerRepository.QueryData(x => x.stationType == 15);
            if (stationManager.Count() > 0)
            var stationManagers = _stationManagerRepository.QueryData(x => x.stationType == 15);
            if (stationManagers.Count() > 0)
            {
                string next = null;
                foreach (var item in stationManager)
                foreach (var item in stationManagers)
                {
                    var x = _taskRepository.QueryFirst(x => x.NextAddress == item.stationChildCode || x.CurrentAddress == item.stationChildCode);
                    if (x == null)
@@ -1104,13 +1192,36 @@
                }
                if (next != null)
                {
                    var stationManager = _stationManagerRepository.QueryFirst(x => x.stationChildCode == next);
                    oldtask.Remark = next;
                    _taskRepository.UpdateData(oldtask);
                    LogAndWarn("中转任务GetDispatchExecutingTask", $" è¿”回任务:【{JsonConvert.SerializeObject(oldtask)}】】");
                    return oldtask;
                    if (task.RGVName == "RGV01")
                    {
                        if (task.TargetStation - stationManager.stationRemark > 1 && task.SourceStation - stationManager.stationRemark > 1 && task.SourceStation - oldtask.SourceStation > 1 && task.TargetStation - oldtask.SourceStation > 1)
                        {
                            _taskRepository.UpdateData(oldtask);
                            LogAndWarn("中转任务GetDispatchExecutingTask", $" è¿”回任务:【{JsonConvert.SerializeObject(oldtask)}】】");
                            return oldtask;
                        }
                        else
                        {
                            return null;
                        }
                    }
                    else
                    {
                        if (stationManager.stationRemark - task.TargetStation > 1 && stationManager.stationRemark - task.SourceStation > 1 && oldtask.SourceStation - task.SourceStation > 1 && oldtask.SourceStation - task.TargetStation > 1)
                        {
                            _taskRepository.UpdateData(oldtask);
                            LogAndWarn("中转任务GetDispatchExecutingTask", $" è¿”回任务:【{JsonConvert.SerializeObject(oldtask)}】】");
                            return oldtask;
                        }
                        else
                        {
                            return null;
                        }
                    }
                }
            }
            return null;
        }