| | |
| | | using Mapster; |
| | | using MapsterMapper; |
| | | using Microsoft.Extensions.Configuration; |
| | | using SqlSugar; |
| | | using System.DirectoryServices.Protocols; |
| | | using System.Text.Json; |
| | | using WIDESEA_Common.Constants; |
| | | using WIDESEA_Common.LocationEnum; |
| | | using WIDESEA_Common.StockEnum; |
| | | using WIDESEA_Common.TaskEnum; |
| | | using WIDESEA_Common.WareHouseEnum; |
| | | using WIDESEA_Core; |
| | | using WIDESEA_Core.BaseRepository; |
| | | using WIDESEA_Core.BaseServices; |
| | | using WIDESEA_Core.Core; |
| | | using WIDESEA_Core.Enums; |
| | | using WIDESEA_Core.Helper; |
| | | using WIDESEA_DTO.GradingMachine; |
| | | using WIDESEA_DTO.MES; |
| | | using WIDESEA_DTO.Stock; |
| | | using WIDESEA_DTO.Task; |
| | | using WIDESEA_IBasicService; |
| | | using WIDESEA_IStockService; |
| | | using WIDESEA_ITaskInfoService; |
| | | using WIDESEA_Model.Models; |
| | | |
| | | namespace WIDESEA_TaskInfoService |
| | |
| | | // 判断是不是极卷库任务 |
| | | if (taskDto.WarehouseId == (int)WarehouseEnum.FJ1 || taskDto.WarehouseId == (int)WarehouseEnum.ZJ1) |
| | | { |
| | | |
| | | return await CompleteAgvInboundTaskAsync(taskDto); |
| | | } |
| | | |
| | |
| | | /// <param name="taskId"></param> |
| | | /// <param name="newStatus"></param> |
| | | /// <returns></returns> |
| | | public async Task<WebResponseContent> UpdateTaskByStatusAsync(int taskId, int newStatus) |
| | | public async Task<WebResponseContent> UpdateTaskByStatusAsync(UpdateTaskDto taskDto) |
| | | { |
| | | try |
| | | { |
| | | var tasks = await BaseDal.QueryFirstAsync(s => s.TaskNum == taskId); |
| | | if (tasks == null) |
| | | var taskInfo = await BaseDal.QueryFirstAsync(s => s.TaskNum == taskDto.Id); |
| | | if (taskInfo == null) |
| | | return WebResponseContent.Instance.Error("未找到对应的任务"); |
| | | |
| | | tasks.TaskStatus = newStatus; |
| | | await BaseDal.UpdateDataAsync(tasks); |
| | | taskInfo.TaskStatus = taskDto.NewStatus; |
| | | taskInfo.NextAddress = taskDto.NextAddress; |
| | | taskInfo.CurrentAddress = taskDto.CurrentAddress; |
| | | await BaseDal.UpdateDataAsync(taskInfo); |
| | | |
| | | return WebResponseContent.Instance.OK("修改成功", tasks); |
| | | return WebResponseContent.Instance.OK("修改成功", taskInfo); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 手动创建任务 |
| | | /// </summary> |
| | | /// <param name="dto">手动创建任务参数</param> |
| | | /// <returns></returns> |
| | | public async Task<WebResponseContent> CreateManualTaskAsync(CreateManualTaskDto dto) |
| | | { |
| | | try |
| | | { |
| | | int taskType; |
| | | int taskStatus; |
| | | switch (dto.TaskType) |
| | | { |
| | | case "入库": |
| | | taskType = TaskInboundTypeEnum.Inbound.GetHashCode(); |
| | | taskStatus = TaskInStatusEnum.InNew.GetHashCode(); |
| | | break; |
| | | |
| | | case "出库": |
| | | taskType = TaskOutboundTypeEnum.Outbound.GetHashCode(); |
| | | taskStatus = TaskOutStatusEnum.OutNew.GetHashCode(); |
| | | break; |
| | | |
| | | case "移库": |
| | | taskType = TaskRelocationTypeEnum.Relocation.GetHashCode(); |
| | | taskStatus = TaskRelocationStatusEnum.RelocationNew.GetHashCode(); |
| | | break; |
| | | |
| | | default: |
| | | return WebResponseContent.Instance.Error($"不支持的任务类型: {dto.TaskType}"); |
| | | } |
| | | |
| | | int taskNum = await BaseDal.GetTaskNo(); |
| | | |
| | | var task = new Dt_Task |
| | | { |
| | | TaskNum = taskNum, |
| | | PalletCode = dto.Barcode, |
| | | SourceAddress = dto.SourceAddress, |
| | | TargetAddress = dto.TargetAddress, |
| | | TaskType = taskType, |
| | | TaskStatus = taskStatus, |
| | | Grade = dto.Grade, |
| | | Roadway = dto.TargetAddress, |
| | | WarehouseId = dto.WarehouseId, |
| | | CurrentAddress = dto.SourceAddress, |
| | | NextAddress = dto.TargetAddress, |
| | | Creater = "manual", |
| | | CreateDate = DateTime.Now, |
| | | ModifyDate = DateTime.Now |
| | | }; |
| | | |
| | | var wmsTaskDtos = new List<WMSTaskDTO>() |
| | | { |
| | | new() |
| | | { |
| | | TaskNum = task.TaskNum, |
| | | PalletCode = task.PalletCode, |
| | | SourceAddress = task.SourceAddress, |
| | | TargetAddress = task.TargetAddress, |
| | | TaskType = task.TaskType, |
| | | Roadway = task.Roadway, |
| | | TaskStatus = task.TaskStatus, |
| | | WarehouseId = task.WarehouseId |
| | | } |
| | | }; |
| | | |
| | | return await _unitOfWorkManage.BeginTranAsync(async () => |
| | | { |
| | | // 4. 保存到数据库 |
| | | var result = await BaseDal.AddDataAsync(task) > 0; |
| | | if (!result) |
| | | return WebResponseContent.Instance.Error("创建任务失败"); |
| | | |
| | | var wcsResult = _httpClientHelper.Post<WebResponseContent>( |
| | | "http://localhost:9292/api/Task/ReceiveManualTask", |
| | | wmsTaskDtos.ToJson()); |
| | | |
| | | if (!wcsResult.IsSuccess || !wcsResult.Data.Status) |
| | | return WebResponseContent.Instance.Error($"任务已创建但发送给WCS失败: {wcsResult.Data?.Message}"); |
| | | |
| | | return WebResponseContent.Instance.OK($"手动创建任务成功,任务号: {taskNum}"); |
| | | }); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return WebResponseContent.Instance.Error($"手动创建任务异常: {ex.Message}"); |
| | | } |
| | | } |
| | | |
| | | #endregion WCS逻辑处理 |
| | | } |
| | | } |