1
huangxiaoqiang
2025-11-10 8f7e6826d51a25c7b368c210dbb321d423d24a85
ÏîÄ¿´úÂë/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs
@@ -490,6 +490,12 @@
        WebResponseContent content = new WebResponseContent();
        try
        {
            var task = BaseDal.QueryFirst(x => x.PalletCode == taskDto.PalletCode);
            if (task != null)
            {
                return content.Error("该托盘已经存在任务,请勿重复下发");
            }
            var boxingInfo = await _boxingInfoRepository.QueryFirstNavAsync(x => x.PalletCode == taskDto.PalletCode && x.StockStatus == (int)StockStateEmun.组盘暂存);
            if (boxingInfo == null)
@@ -983,7 +989,7 @@
        }
        if (!LocationIsOutBound(StartAddress))
        {
            throw new Exception($"起点库位{StartAddress.LocationCode}出库路径被占用,请人工确认再下发任务");
            throw new Exception($"起点库位{StartAddress.LocationCode}出库路径被占用,请稍后重试");
        }
        DtLocationInfo location = null;
        if (taskDto.AreaId != 0)
@@ -1255,6 +1261,10 @@
                //todo查询内侧库存信息
                var stock = await _stockInfoRepository.QueryFirstAsync(x => x.LocationCode == locationLateral.LocationCode);
                if (stock == null)
                {
                    return content.Error($"未找到浅位{locationLateral.LocationCode}库存信息");
                }
                Dt_Task taskNew = new Dt_Task
                {
                    Grade = 1,
@@ -1277,7 +1287,6 @@
                var taskDTO = CreateListTaskDTO(taskNew);
                var isResult = await AddTaskAsync(taskNew, locationLateral, TargetAddress);
                //UpdateLocationStatus(TargetAddress, LocationEnum.Lock);
                UpdateLocationStatus(TargetAddress, LocationEnum.Lock, taskNew.TaskNum.Value, (int)StatusChangeTypeEnum.AutomaticRelocation);
                if (!isResult)
                {
@@ -1350,28 +1359,43 @@
                        return content.Error("起点未定义或终点区域未找到空闲库位");
                    }
                    //todo查询移库库存信息
                    Dt_Task taskNew = new Dt_Task
                    var stock = _stockInfoRepository.QueryFirst(x => x.LocationCode == item.LocationCode);
                    if (stock == null)
                    {
                        Grade = item.Column,
                        Roadway = "AGV",
                        TargetAddress = Targetlocation.LocationCode,
                        Dispatchertime = DateTime.Now,
                        MaterialNo = "",
                        NextAddress = Targetlocation.LocationCode,
                        OrderNo = null,
                        PalletCode = _random.Next(0, 10000).ToString(),
                        SourceAddress = item.LocationCode,
                        CurrentAddress = item.LocationCode,
                        TaskState = (int)TaskAGVCarryStatusEnum.CarryNew,
                        TaskType = (int)TaskRelocationTypeEnum.Relocation,
                        TaskNum = BaseDal.GetTaskNo().Result,
                        CreateDate = DateTime.Now,
                        TaskId = 0,
                        AGVTaskNum = GenerateUniqueId(),
                        Floor = item.Floor,
                        Remark = item.AreaId.ToString(),
                    };
                        return content.Error($"未找到浅位{item.LocationCode}库存信息");
                    }
                    var Relocationtask = BaseDal.QueryFirst(x => x.PalletCode == stock.PalletCode && x.TaskType == (int)TaskRelocationTypeEnum.Relocation);
                    Dt_Task taskNew = new Dt_Task();
                    if (Relocationtask != null)
                    {
                        taskDTO.Add(CreateTaskDTO(Relocationtask));
                        //return content.OK(data:taskDTO);
                        continue;
                    }
                    else
                    {
                        taskNew = new Dt_Task
                        {
                            Grade = item.Column,
                            Roadway = "AGV",
                            TargetAddress = Targetlocation.LocationCode,
                            Dispatchertime = DateTime.Now,
                            MaterialNo = "",
                            NextAddress = Targetlocation.LocationCode,
                            OrderNo = null,
                            PalletCode = stock.PalletCode,
                            SourceAddress = item.LocationCode,
                            CurrentAddress = item.LocationCode,
                            TaskState = (int)TaskAGVCarryStatusEnum.CarryNew,
                            TaskType = (int)TaskRelocationTypeEnum.Relocation,
                            TaskNum = BaseDal.GetTaskNo().Result,
                            CreateDate = DateTime.Now,
                            TaskId = 0,
                            AGVTaskNum = GenerateUniqueId(),
                            Floor = item.Floor,
                            Remark = item.AreaId.ToString(),
                        };
                    }
                    taskDTO.Add(CreateTaskDTO(taskNew));
                    var isResult = await AddTaskAsync(taskNew, item, Targetlocation);
@@ -2079,6 +2103,7 @@
            TaskState = task.TaskState,
            Id = 0,
            TaskType = task.TaskType,
            Floor =task.Floor,
            AGVTaskNum = task.AGVTaskNum,
        } };
    }
@@ -2097,7 +2122,8 @@
            Id = 0,
            TaskType = task.TaskType,
            AGVTaskNum = task.AGVTaskNum,
            Remark= task.Remark
            Remark = task.Remark,
            Floor = task.Floor,
        };
    }
@@ -2281,7 +2307,7 @@
                TaskNum = task.TaskNum.Value,
                LocationId = StartAddress.Id,
                LocationCode = StartAddress.LocationCode,
                ChangeType = (int)StatusChangeTypeEnum.AutomaticInbound,
                ChangeType = (int)StatusChangeTypeEnum.AutomaticRelocation,
            },
            new LocationChangeRecordDto()
            {
@@ -2290,7 +2316,7 @@
                TaskNum = task.TaskNum.Value,
                LocationId = EndAddress.Id,
                LocationCode = EndAddress.LocationCode,
                ChangeType = (int)StatusChangeTypeEnum.AutomaticInbound,
                ChangeType = (int)StatusChangeTypeEnum.AutomaticRelocation,
            },
        };