| | |
| | | using AutoMapper; |
| | | using SqlSugar; |
| | | using System.Diagnostics.CodeAnalysis; |
| | | using System.Text.Json; |
| | | using WIDESEAWCS_Common.HttpEnum; |
| | | using WIDESEAWCS_Common.TaskEnum; |
| | | using WIDESEAWCS_Core; |
| | | using WIDESEAWCS_Core.BaseServices; |
| | | using WIDESEAWCS_Core.Enums; |
| | | using WIDESEAWCS_Core.Http; |
| | | using WIDESEAWCS_DTO.TaskInfo; |
| | | using WIDESEAWCS_ITaskInfoRepository; |
| | | using WIDESEAWCS_ITaskInfoService; |
| | |
| | | |
| | | if (task.TaskState == (int)TaskInStatusEnum.Line_InFinish) |
| | | { |
| | | Random random = new Random(); |
| | | //Random random = new Random(); |
| | | //task.CurrentAddress = task.NextAddress; |
| | | //task.NextAddress = $"{random.Next(1, 100).ToString().PadLeft(3, '0')}-{random.Next(1, 100).ToString().PadLeft(3, '0')}-{random.Next(1, 100).ToString().PadLeft(3, '0')}"; |
| | | //task.TargetAddress = task.NextAddress; |
| | | |
| | | // 调用WMS系统接口,获取最终目标地址 |
| | | CreateTaskDto taskDto = new CreateTaskDto() |
| | | { |
| | | Roadway = task.TargetAddress, |
| | | PalletCode = task.PalletCode, |
| | | SourceAddress = task.SourceAddress, |
| | | // 目标地址待定 |
| | | TargetAddress = "CLOutAreaA", |
| | | TaskType = task.TaskType, |
| | | }; |
| | | content = HttpRequestHelper.HTTPPostAsync(nameof(Category.WMS), taskDto.ToString(), nameof(ConfigKey.GetTasksLocation)).Result; |
| | | if (!content.Status) |
| | | { |
| | | return WebResponseContent.Instance.Error($"调用WMS接口获取任务目标地址失败,任务号:【{task.TaskNum}】,错误信息:【{content.Message}】"); |
| | | } |
| | | |
| | | string wmsTargetAddress = content.Data?.ToString() ?? string.Empty; |
| | | if (string.IsNullOrEmpty(wmsTargetAddress)) |
| | | { |
| | | return WebResponseContent.Instance.Error($"调用WMS接口获取任务目标地址失败,任务号:【{task.TaskNum}】,错误信息:【未获取到有效的目标地址】"); |
| | | } |
| | | |
| | | task.NextAddress = wmsTargetAddress; |
| | | task.TargetAddress = wmsTargetAddress; |
| | | task.CurrentAddress = task.NextAddress; |
| | | task.NextAddress = $"{random.Next(1, 100).ToString().PadLeft(3, '0')}-{random.Next(1, 100).ToString().PadLeft(3, '0')}-{random.Next(1, 100).ToString().PadLeft(3, '0')}"; |
| | | task.TargetAddress = task.NextAddress; |
| | | } |
| | | } |
| | | else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OtherGroup) |
| | |
| | | string oldCurrentPos = task.CurrentAddress; |
| | | string oldNextPos = task.NextAddress; |
| | | |
| | | List<Dt_Router> routers = _routerService.QueryNextRoutes(task.NextAddress, task.TargetAddress); |
| | | if (!routers.Any()) throw new Exception($"未找到设备路由信息"); |
| | | Dt_Router routers = _routerService.QueryNextRoute(task.CurrentAddress); |
| | | if (routers == null) throw new Exception($"未找到设备路由信息"); |
| | | |
| | | task.CurrentAddress = task.NextAddress; |
| | | task.NextAddress = routers.FirstOrDefault().ChildPosi; |
| | | task.NextAddress = routers.ChildPosi; |
| | | |
| | | task.ModifyDate = DateTime.Now; |
| | | task.Modifier = "System"; |
| | |
| | | else |
| | | return BaseDal.QueryFirst(x => x.Roadway == deviceNo && TaskRobotTypes.Contains(x.TaskType) && x.CurrentAddress == currentAddress && x.TaskState <= (int)TaskRobotStatusEnum.RobotExecuting, TaskOrderBy); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取与指定任务编号关联的任务。 |
| | | /// </summary> |
| | | /// <param name="taskNum">要获取的任务的唯一标识符。</param> |
| | | /// <returns>表示指定编号任务的<see cref="Dt_Task"/>对象,如果不存在该任务则返回<c>null</c>。</returns> |
| | | public Dt_Task QueryByTaskNum(int taskNum) |
| | | { |
| | | return BaseDal.QueryFirst(x => x.TaskNum == taskNum); |
| | | } |
| | | } |
| | | } |