Admin
2026-01-29 4e051ed24849863a068c66b72c4c883985b2ec23
ÏîÄ¿´úÂë/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/Partial/SCExecutionBlock.cs
@@ -47,12 +47,34 @@
                if (dt_Location.Depth == 1 && dt_Task.TaskType == (int)TaskTypeEnum.Inbound)
                {
                    if (shallowLocation.LocationStatus == (int)LocationStatusEnum.InStock) return content.OK();
                    return content.Error();
                    return content.Error($"入库至深库位,但是浅货位有货,任务号:{dt_Task.TaskId},托盘条码");
                }
                if (shallowLocation.LocationStatus == (int)LocationStatusEnum.Free) return content.OK();
                //判断是否有移库任务
                //判断当前浅货位是否有出库任务
                var OutTask = _taskService.GeOutCuTaskQueue(shallowLocation.LocationCode);
                if (OutTask != null)
                {
                    //进行下发给堆垛机任务
                    WCSginseng outresult = _taskService.SC_IssueTasks(OutTask.TaskId, int.Parse(OutTask.Roadway), OutTask.TaskNum, OutTask.PalletCode, int.Parse(OutTask.PalletType), OutTask.CurrentAddress, OutTask.NextAddress, OutTask.TargetAddress);
                    if (outresult.IsSuccess)
                    {
                        OutTask.TaskStatus = (int)OutTaskStatusEnum.SC_OutExecuting;
                        _taskService.UpdateData(OutTask);
                        return content.OK();
                    }
                    else
                    {
                        UpdateTaskStatus(dt_Task, outresult,0, 1);
                        return content.Error($"下发wcs失败,原因:{outresult.Message}");
                    }
                }
                //判断是否有移库任务
                var TransferTask = _taskService.GeRelocationTaskQueue(shallowLocation.LocationCode);
                if (TransferTask != null)
                {
@@ -66,17 +88,15 @@
                    }
                    else
                    {
                        UpdateTaskStatus(dt_Task, result,
                        successStatus: dt_Task.TaskStatus == (int)InTaskStatusEnum.PLC_InFinish ? (int)InTaskStatusEnum.SC_IntExecuting : (int)OutTaskStatusEnum.SC_OutExecuting, 1);
                        UpdateTaskStatus(dt_Task, result,0,1);  //默认不需要更改状态传0
                        WriteLog.Write_Log("WMS_判断巷道内移库", $"判断移库", "失败", $"原因:{result.Message}");
                        return content.Error();
                        return content.Error($"下发wcs失败,原因:{result.Message}");
                    }
                }
                var CuttTransferTask = _taskService.RelocationTaskProgress(dt_Task.Roadway);
                //判断当前是否有移库任务
                if (CuttTransferTask != null) return content.Error();
                if (CuttTransferTask) return content.Error("当前有移库任务,不可下发");
                if (shallowLocation.LocationStatus != (int)LocationStatusEnum.InStock) return content.Error();
@@ -86,11 +106,12 @@
            }
            catch (Exception ex)
            {
                WriteLog.Write_Log("WMS_判断巷道内移库", $"判断移库", "失败,方法内故障", $"原因:{ex.Message}");
                return content.Error();
                return content.Error($"判断巷道内移库,失败,方法内故障,原因:{ex.Message}");
            }
        }
        public WebResponseContent GenerateTransferTask(string shallowLocation)
@@ -103,7 +124,66 @@
                Dt_LocationInfo newLocation = _locationInfoService.GetLocation(OriginalLocation.RoadwayNo, OriginalLocation.LocationType);
                List<Dt_LocationInfo> dt_Locations = new List<Dt_LocationInfo>();
                MES_parameter mES_Parame = _taskService.ApplicationChangeStorageLocation(dt_StockInfo.PalletCode, OriginalLocation.LocationCode, newLocation.LocationCode);
                var TransferTask = _taskService.GeRelocationTaskQueue(shallowLocation);
                //进行生成任务,下发任务至MES
                Dt_Task task = new Dt_Task();
                task.TaskNum = "0";
                task.PalletCode = dt_StockInfo.PalletCode;
                task.PalletType = dt_StockInfo.PalletType;
                task.Roadway = OriginalLocation.RoadwayNo;
                task.TaskType = (int)TaskTypeEnum.Relocation;
                task.TaskStatus = (int)RelocationTaskStatusEnum.RelocationNew;
                task.SourceAddress = OriginalLocation.LocationCode;
                task.TargetAddress = newLocation.LocationCode;
                task.CurrentAddress = OriginalLocation.LocationCode;
                task.NextAddress = newLocation.LocationCode;
                task.WarehouseId = OriginalLocation.WarehouseId;
                task.OrderNo = "";
                task.Grade = 1;
                task.Creater = "MES";
                task.CreateDate = DateTime.Now;
                OriginalLocation.LocationStatus = (int)LocationStatusEnum.Lock;
                newLocation.LocationStatus = (int)LocationStatusEnum.Lock;
                dt_StockInfo.StockStatus = (int)StockStatusEmun.移库锁定;
                dt_Locations.Add(OriginalLocation);
                dt_Locations.Add(newLocation);
                _unitOfWorkManage.BeginTran();
                int TaskId = _taskService.Repository.AddData(task);
                _locationInfoService.UpdateData(dt_Locations);
                _stockInfoService.UpdateData(dt_StockInfo);
                _unitOfWorkManage.CommitTran();
                return webResponse.Error("已生成移库任务");
                //进行下发给堆垛机任务
                /*WCSginseng result = _taskService.SC_IssueTasks(
                    TaskId,
                    int.Parse(task.Roadway),
                    task.TaskNum,
                    task.PalletCode,
                    int.Parse(task.PalletType),
                    task.CurrentAddress,
                    task.NextAddress,
                    task.TargetAddress);
                if (result.IsSuccess)
                {
                    Dt_Task dt_Task=_taskService.Repository.QueryFirst(x=>x.TaskId== task.TaskId);
                    dt_Task.TaskStatus = (int)RelocationTaskStatusEnum.RelocationExecuting;
                    _taskService.UpdateData(dt_Task);
                    return webResponse.OK();
                }
                else
                {
                    return webResponse.Error($"下发移库失败,原因:{result.Message}");
                }*/
                /*MES_parameter mES_Parame = _taskService.ApplicationChangeStorageLocation(dt_StockInfo.PalletCode, OriginalLocation.LocationCode, newLocation.LocationCode);
                if (mES_Parame != null)
                {
                    if (mES_Parame.Result == "Y")
@@ -160,28 +240,23 @@
                        }
                        else
                        {
                            WriteLog.Write_Log("WMS_判断巷道内移库", $"移库任务生成方法", "下发移库失败", $"原因:{result.Message}");
                            return webResponse.Error();
                            return webResponse.Error($"下发移库失败,原因:{result.Message}");
                        }
                    }
                    else
                    {
                        WriteLog.Write_Log("WMS_判断巷道内移库", $"移库任务生成方法", "申请MES移库", $"申请储位异动,MES不允许移动");
                        return webResponse.Error();
                        return webResponse.Error($"申请储位异动,MES不允许移动====>>>>返回内容:{mES_Parame.ToJson()}");
                    }
                }
                else
                {
                    WriteLog.Write_Log("WMS_判断巷道内移库", $"移库任务生成方法", "申请MES移库,返回空", $"申请储位异动,MES返回为空");
                    return webResponse.Error();
                }
                    return webResponse.Error("申请储位异动,MES返回为空");
                }*/
            }
            catch (Exception ex)
            {
                _unitOfWorkManage.RollbackTran();
                WriteLog.Write_Log("WMS_判断巷道内移库", $"移库任务生成方法", "系统故障", $"原因:{ex.Message}");
                return webResponse.Error();
                return webResponse.Error($"移库任务生成方法,系统故障,原因:{ex.Message}");
            }
        }