| | |
| | | { |
| | | try |
| | | { |
| | | var dt_Task = await BaseDal.QueryFirstAsync(x => x.TargetAddress == taskDto.TargetAddress); |
| | | if (!dt_Task.IsNullOrEmpty()) |
| | | { |
| | | var taskDTO = dt_Task.Adapt<WMSTaskDTO>(); |
| | | return WebResponseContent.Instance.OK("任务创建成功", taskDTO); |
| | | } |
| | | |
| | | var stockInfo = await _stockInfoService.Repository.QueryDataNavFirstAsync(x => x.LocationDetails.WarehouseId == taskDto.WarehouseId && x.LocationDetails.LocationStatus == LocationStatusEnum.InStock.GetHashCode() && x.StockStatus == StockStatusEmun.空托盘库存.GetHashCode()); |
| | | if (stockInfo == null) |
| | | return WebResponseContent.Instance.Error("未找到对应的库存信息"); |
| | |
| | | TaskNum = await BaseDal.GetTaskNo(), |
| | | Creater = "system", |
| | | }; |
| | | var taskDtos = task.Adapt<WMSTaskDTO>(); |
| | | |
| | | var addResult = await BaseDal.AddDataAsync(task) > 0; |
| | | if (!addResult) |
| | | return WebResponseContent.Instance.Error("任务创建失败"); |
| | | return WebResponseContent.Instance.OK("任务创建成功", taskDtos); |
| | | return await ExecuteWithinTransactionAsync(async () => |
| | | { |
| | | var locationInfo = await _locationInfoService.GetLocationInfoAsync(stockInfo.LocationId); |
| | | locationInfo.LocationStatus = LocationStatusEnum.InStockLock.GetHashCode(); |
| | | var updateLocationResult = await _locationInfoService.UpdateLocationInfoAsync(locationInfo); |
| | | if (!updateLocationResult) |
| | | return WebResponseContent.Instance.Error("任务创建失败"); |
| | | |
| | | var taskDtos = task.Adapt<WMSTaskDTO>(); |
| | | |
| | | var addResult = await BaseDal.AddDataAsync(task) > 0; |
| | | if (!addResult) |
| | | return WebResponseContent.Instance.Error("任务创建失败"); |
| | | return WebResponseContent.Instance.OK("任务创建成功", taskDtos); |
| | | }); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | |
| | | if (stockInfo.LocationId > 0 || !string.IsNullOrWhiteSpace(stockInfo.LocationCode)) |
| | | return WebResponseContent.Instance.Error($"托盘[{stockPalletCode}]库存已绑定货位,不能创建机械手{taskName}任务"); |
| | | } |
| | | var section = App.Configuration.GetSection("RobotTaskAddressRules").GetSection(targetLineNo).GetChildren().Select(c => c.Value).ToArray(); |
| | | |
| | | var task = new Dt_Task |
| | | { |
| | |
| | | Roadway = stock.Roadway ?? string.Empty, |
| | | TaskType = taskType.GetHashCode(), |
| | | TaskStatus = TaskRobotStatusEnum.RobotNew.GetHashCode(), |
| | | SourceAddress = sourceLineNo, |
| | | TargetAddress = targetLineNo, |
| | | CurrentAddress = sourceLineNo, |
| | | SourceAddress = section[0], |
| | | TargetAddress = section[1], |
| | | CurrentAddress = targetLineNo, |
| | | NextAddress = targetLineNo, |
| | | WarehouseId = stockInfo?.WarehouseId ?? 1, |
| | | Grade = 1, |