duyongjia
2024-11-22 a89f1faab22c204627d49d6731be9c94d8160184
´úÂë¹ÜÀí/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs
@@ -468,7 +468,7 @@
            }
            catch (Exception ex)
            {
                ServiceLogger.WriteDebug("ReceiveTask", $"任务接收错误,错误信息:{ex.Message}");
                ServiceLogger.WriteDebug("ReceiveTask", $"任务接收错误,错误信息:{ex.StackTrace}");
                content = WebResponseContent.Instance.Error($"任务接收错误,错误信息:{ex.Message}");
            }
            return content;
@@ -884,6 +884,7 @@
                    catch (Exception ex)
                    {
                        _unitOfWorkManage.RollbackTran();
                        //任务执行失败,货位状态还原
                        ServiceLogger.WriteDebug("StackCraneTaskCompleted", $"大堆垛机执行出库任务失败!,任务号:【{taskNum}】,失败信息:【{ex.Message}】");
                        content = WebResponseContent.Instance.Error($"大堆垛机执行出库任务失败!,任务号:【{taskNum}】,失败信息:【{ex.Message}】");
                    }
@@ -982,7 +983,7 @@
                {
                    try
                    {
                        Dt_LocationInfo srcLocation = _locationInfoRepository.QueryFirst(x => x.LocationCode == task.SourceAddress);
                        //Dt_LocationInfo srcLocation = _locationInfoRepository.QueryFirst(x => x.LocationCode == task.SourceAddress);
                        //srcLocation.LocationStatus = (int)LocationStatusEnum.Free;
                        
@@ -1002,44 +1003,45 @@
                        MESResponse res = ApiInvoke.SendTaskCMD(sendcmd);
                        if (res != null && res.code != 0)
                        {
                            ServiceLogger.WriteDebug("StackCraneTaskCompleted", $"小堆垛机完成出库任务后回传MES失败!,任务号:【{taskNum}】,失败信息:【{res.message}】");
                            content = WebResponseContent.Instance.Error($"小堆垛机完成出库任务后回传MES失败!,任务号:【{taskNum}】,失败信息:【{res.message}】");
                        }
                        else
                        {
                            //判断是否完成的最后一层,自动生成空车出库任务
                            string[] Levels = task.Remark.Split("-");
                            if (Levels.Length == 2)
                            {
                                if (!string.IsNullOrEmpty(Levels[0])&& !string.IsNullOrEmpty(Levels[1]))
                                {
                                    //如果当前提取层数等于总层料,则表示料车所有的层数取完
                                    if(Convert.ToInt16(Levels[0])== Convert.ToInt16(Levels[1]))
                                    {
                                        string[] SourceCodes = task.SourceAddress.Split("-");
                                        string startPlan = "";
                                        if (SourceCodes.Length == 4)
                                        {
                                            startPlan= "101"+ SourceCodes[2].Substring(1,2);
                                        }
                                        DeliveryPlan send = new DeliveryPlan { startPlan = startPlan, isQuit = false, CarId = task.PalletCode };
                                        string inparam2 = JsonConvert.SerializeObject(send);
                                        ServiceLogger.WriteDebug("StackCraneTaskCompleted", $"小堆垛机执行出库任务回传MES入参{inparam2}");
                                        ApiInvoke.DeliveryPlanCMD(send);//回调MES接口生成空车出库任务
                                        //所有的层数都取完,需要把暂存位状态改为空闲状态
                                        srcLocation.LocationStatus = (int)LocationStatusEnum.Free;
                                        _locationInfoRepository.UpdateData(srcLocation);
                                    }
                        //else
                        //{
                        //    //判断是否完成的最后一层,自动生成空车出库任务
                        //    string[] Levels = task.Remark.Split("-");
                        //    if (Levels.Length == 2)
                        //    {
                        //        if (!string.IsNullOrEmpty(Levels[0])&& !string.IsNullOrEmpty(Levels[1]))
                        //        {
                        //            //如果当前提取层数等于总层料,则表示料车所有的层数取完
                        //            if(Convert.ToInt16(Levels[0])== Convert.ToInt16(Levels[1]))
                        //            {
                        //                string[] SourceCodes = task.SourceAddress.Split("-");
                        //                string startPlan = "";
                        //                if (SourceCodes.Length == 4)
                        //                {
                        //                    startPlan = "101" + SourceCodes[2].Substring(1, 2);
                        //                }
                        //                DeliveryPlan send = new DeliveryPlan { startPlan = startPlan, isQuit = false, CarId = task.PalletCode };
                        //                string inparam2 = JsonConvert.SerializeObject(send);
                        //                ServiceLogger.WriteDebug("StackCraneTaskCompleted", $"小堆垛机执行出库任务回传MES入参{inparam2}");
                        //                ApiInvoke.DeliveryPlanCMD(send);//回调MES接口生成空车出库任务
                        //                æ‰€æœ‰çš„层数都取完,需要把暂存位状态改为空闲状态
                        //                srcLocation.LocationStatus = (int)LocationStatusEnum.Free;
                        //                _locationInfoRepository.UpdateData(srcLocation);
                        //            }
                                }
                        //        }
                              
                            }
                        }
                        //    }
                        //}
                    }
                    catch (Exception ex)
                    {
                        _unitOfWorkManage.RollbackTran();
                        ServiceLogger.WriteDebug("StackCraneTaskCompleted", $"小堆垛机执行出库任务失败!,任务号:【{taskNum}】,失败信息:【{ex.Message}】");
                        ServiceLogger.WriteDebug("StackCraneTaskCompleted", $"小堆垛机执行出库任务失败!,任务号:【{taskNum}】,失败信息:【{ex.StackTrace}】");
                        content = WebResponseContent.Instance.Error($"小堆垛机执行出库任务失败!,任务号:【{taskNum}】,失败信息:【{ex.Message}】");
                    }
@@ -1060,6 +1062,8 @@
            return content;
        }
        /// <summary>
        /// æ¢å¤æŒ‚起任务
        /// </summary>