duyongjia
2024-11-22 a89f1faab22c204627d49d6731be9c94d8160184
´úÂë¹ÜÀí/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs
@@ -49,6 +49,8 @@
        public Task Execute(IJobExecutionContext context)
        {
            WriteDebug("大堆垛机运行日志", "开始时间" + DateTime.Now);
            WriteDebug("大堆垛机运行日志", $"大堆垛机任务执行中...");
            //CommonStackerCrane commonStackerCrane = (CommonStackerCrane)context.JobDetail.JobDataMap.Get("JobParams");
            CommonStackerCrane commonStackerCrane = Storage.Devices.FirstOrDefault(x => x.DeviceCode == "SC01") as CommonStackerCrane;
            try
@@ -69,6 +71,7 @@
                            Dt_Task? task = GetTask(commonStackerCrane);
                            if (task != null)
                            {
                                WriteDebug("大堆垛机运行日志", $"大堆垛机任务号{task.TaskNum}");
                                StackerCraneTaskCommand? stackerCraneTaskCommand = ConvertToStackerCraneTaskCommand(task);
                                if (stackerCraneTaskCommand != null)
                                {
@@ -105,13 +108,13 @@
            //查询提升机/组立机信号
            Task.Run(delegate
            {
            //Task.Run(delegate
            //{
                try
                {
                    if (commonStackerCrane != null)
                    {
                        Dt_Task? task1001 = _taskService.QueryStackerCraneTaskByAGVRequest("SC01");
                        if (task1001 != null)
                        {
@@ -143,12 +146,13 @@
                            int IsWriteTwo = 0;
                            if (task3001.SourceAddress == "SC01-002-000-001")//WMS 1001站点
                            {
                                //提升机是否处于就绪状态
                                int IsReady= commonStackerCrane.Communicator.Read<short>("DB2.0.0");
                                //写入提升信息
                                IsWriteOne = commonStackerCrane.Communicator.Read<short>("DB1.0.0");
                                if(IsWriteOne == 0)
                                if(IsWriteOne == 0&& IsReady == 1)
                                {
                                   var d= commonStackerCrane.Communicator.Write<short>("DB1.0.0", 1);
                                   commonStackerCrane.Communicator.Write<short>("DB1.0.0", 1);
                                }
                                //读取提升机信号,确定是否提升完成
                               
@@ -156,9 +160,11 @@
                            }
                            else if (task3001.SourceAddress == "SC01-002-000-002")//WMS 1002站点
                            {
                                //提升机是否处于就绪状态
                                int IsReady = commonStackerCrane.Communicator.Read<short>("DB2.0.0");
                                //写入提升信息
                                IsWriteTwo = commonStackerCrane.Communicator.Read<short>("DB1.6.0");
                                if (IsWriteTwo == 0)
                                if (IsWriteTwo == 0 && IsReady == 1)
                                {
                                    commonStackerCrane.Communicator.Write<short>("DB1.6.0", 1);
                                }    
@@ -176,8 +182,6 @@
                                {
                                    WriteDebug(nameof(CommonStackerCraneJob), $"提升机提升完成,回传WMS失败!任务号{task3001.TaskNum}");
                                }
                            }
                        }
@@ -195,8 +199,12 @@
                                    if (!string.IsNullOrEmpty(Levels[0]) && !string.IsNullOrEmpty(Levels[1]))
                                    {
                                        int level = Convert.ToInt16(Levels[0]) - Convert.ToInt16(Levels[1]);
                                        //剩余层数写入
                                        bool issuccess = commonStackerCrane.Communicator.Write<short>("DB28." + location.Depth + ".0", Convert.ToInt16(level));
                                        WriteDebug(nameof(CommonStackerCraneJob), $"剩余层数信号写入{level}-任务号{taskSmall.TaskNum}");
                                        //如果当前提取层数等于总层数,则表示料车所有的层数取完
                                        if (level == 0)
                                        {
@@ -205,8 +213,21 @@
                                            {
                                                //根据目标地址查询组立机站点信息,获取写入整车完成的DB块 Depth
                                                Dt_LocationInfo location2 = _locationInfoRepository.QueryFirst(x => x.LocationCode == location.Remark);
                                                //整车完成写入
                                                bool issuccess2 = commonStackerCrane.Communicator.Write<short>("DB28." + location.Depth+".0", 1);
                                            //整车完成写入层数
                                            int sn = 0;
                                            if(taskSmall.SourceAddress== "SC01-001-006-001"|| taskSmall.SourceAddress == "SC01-001-012-001"|| taskSmall.SourceAddress == "SC01-001-018-001" || taskSmall.SourceAddress == "SC01-001-022-001"|| taskSmall.SourceAddress == "SC01-001-026-001")
                                            {
                                                sn = 1;
                                            }
                                            else if(taskSmall.SourceAddress == "SC01-001-007-001" || taskSmall.SourceAddress == "SC01-001-013-001" || taskSmall.SourceAddress == "SC01-001-019-001" || taskSmall.SourceAddress == "SC01-001-023-001" || taskSmall.SourceAddress == "SC01-001-027-001")
                                            {
                                                sn = 2;
                                            }
                                            else
                                            {
                                                sn = 3;
                                            }
                                            bool issuccess2 = commonStackerCrane.Communicator.Write<short>("DB28." + location2.Depth+".0", Convert.ToInt16(sn));
                                                if (issuccess2&&issuccess)
                                                {
                                                    _taskService.UpdateTaskStatus(taskSmall.TaskId, (int)TaskOutStatusEnum.OutFinish);
@@ -238,20 +259,15 @@
                            }
                            
                        }
                    }
                }
                }
                catch (Exception ex)
                {
                    WriteError(nameof(CommonStackerCraneJob), "查询或写入PLC状态失败!", ex);
                }
            });
            WriteDebug("大堆垛机运行日志", "结束时间" + DateTime.Now);
            //});
            return Task.CompletedTask;
        }