| | |
| | | using Serilog.Core; |
| | | using System.Diagnostics.CodeAnalysis; |
| | | using WIDESEAWCS_Common.TaskEnum; |
| | | using WIDESEAWCS_Core; |
| | |
| | | using WIDESEAWCS_DTO.TaskInfo; |
| | | using WIDESEAWCS_Model.Models; |
| | | using WIDESEAWCS_QuartzJob.Models; |
| | | using WIDESEAWCS_Tasks; |
| | | |
| | | namespace WIDESEAWCS_TaskInfoService; |
| | | |
| | |
| | | /// <returns></returns> |
| | | public WebResponseContent UpdateTaskStatusToNext([NotNull] Dt_Task task) |
| | | { |
| | | int oldState = task.TaskStatus; |
| | | |
| | | var result = task.TaskType.GetTaskTypeGroup() switch |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | TaskTypeGroup.OutbondGroup => _outboundTaskFlowService.MoveToNextStatus(task), |
| | | TaskTypeGroup.InboundGroup => _inboundTaskFlowService.MoveToNextStatus(task), |
| | | TaskTypeGroup.RelocationGroup => _relocationTaskFlowService.MoveToNextStatus(task), |
| | | TaskTypeGroup.OtherGroup => _robotTaskFlowService.MoveToNextStatus(task), |
| | | _ => WebResponseContent.Instance.Error($"任务类型错误,未找到该任务类型,任务号:【{task.TaskNum}】,任务类型:【{task.TaskType}】") |
| | | }; |
| | | int oldState = task.TaskStatus; |
| | | |
| | | if (!result.Status) |
| | | return result; |
| | | var result = task.TaskType.GetTaskTypeGroup() switch |
| | | { |
| | | TaskTypeGroup.OutbondGroup => _outboundTaskFlowService.MoveToNextStatus(task), |
| | | TaskTypeGroup.InboundGroup => _inboundTaskFlowService.MoveToNextStatus(task), |
| | | TaskTypeGroup.RelocationGroup => _relocationTaskFlowService.MoveToNextStatus(task), |
| | | TaskTypeGroup.OtherGroup => _robotTaskFlowService.MoveToNextStatus(task), |
| | | _ => content.Error($"任务类型错误,未找到该任务类型,任务号:【{task.TaskNum}】,任务类型:【{task.TaskType}】") |
| | | }; |
| | | |
| | | // 出库完成线体节点时,可能需要接收入库新任务。 |
| | | if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup |
| | | && result.Data is List<WMSTaskDTO> wmsTasks |
| | | && wmsTasks.Count > 0) |
| | | { |
| | | WebResponseContent content = ReceiveWMSTask(wmsTasks); |
| | | if (!content.Status) |
| | | return content; |
| | | if (!result.Status) |
| | | return result; |
| | | |
| | | // 出库完成线体节点时,可能需要接收入库新任务。 |
| | | if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup |
| | | && result.Data is List<WMSTaskDTO> wmsTasks |
| | | && wmsTasks.Count > 0) |
| | | { |
| | | content = ReceiveWMSTask(wmsTasks); |
| | | if (!content.Status) |
| | | return content; |
| | | } |
| | | |
| | | // 更新任务数据 |
| | | task.ModifyDate = DateTime.Now; |
| | | task.Modifier = "System"; |
| | | if (task.TaskStatus == (int)TaskOutStatusEnum.Line_OutFinish) |
| | | { |
| | | BaseDal.DeleteAndMoveIntoHty(task, OperateTypeEnum.自动完成); |
| | | } |
| | | else |
| | | { |
| | | BaseDal.UpdateData(task); |
| | | } |
| | | |
| | | // 记录任务执行详情 |
| | | string logMessage = App.User.UserId > 0 |
| | | ? $"人工手动将任务状态从【{oldState}】跳转到【{task.TaskStatus}】" |
| | | : $"系统自动流程,任务状态从【{oldState}】转到【{task.TaskStatus}】"; |
| | | _taskExecuteDetailService.AddTaskExecuteDetail(task.TaskId, logMessage); |
| | | |
| | | return content.OK(); |
| | | } |
| | | |
| | | // 更新任务数据 |
| | | task.ModifyDate = DateTime.Now; |
| | | task.Modifier = "System"; |
| | | if (task.TaskStatus == (int)TaskOutStatusEnum.Line_OutFinish) |
| | | catch (Exception ex) |
| | | { |
| | | BaseDal.DeleteAndMoveIntoHty(task, OperateTypeEnum.自动完成); |
| | | QuartzLogHelper.LogError(Logger.None, $"UpdateTaskStatusToNext 更新将任务状态修改为下一个状态失败,任务号:【{task.TaskNum}】,错误信息:【{ex.Message}】", "UpdateTaskStatusToNext"); |
| | | return content.Error(ex.Message); |
| | | } |
| | | else |
| | | { |
| | | BaseDal.UpdateData(task); |
| | | } |
| | | |
| | | // 记录任务执行详情 |
| | | string logMessage = App.User.UserId > 0 |
| | | ? $"人工手动将任务状态从【{oldState}】跳转到【{task.TaskStatus}】" |
| | | : $"系统自动流程,任务状态从【{oldState}】转到【{task.TaskStatus}】"; |
| | | _taskExecuteDetailService.AddTaskExecuteDetail(task.TaskId, logMessage); |
| | | |
| | | return WebResponseContent.Instance.OK(); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | Console.WriteLine($"UpdatePosition 更新任务位置失败,任务号:【{taskNum}】,错误信息:【{ex.Message}】"); |
| | | QuartzLogHelper.LogError(Logger.None, $"UpdatePosition 更新任务位置失败,任务号:【{taskNum}】,错误信息:【{ex.Message}】", "UpdatePosition"); |
| | | //Console.WriteLine($"UpdatePosition 更新任务位置失败,任务号:【{taskNum}】,错误信息:【{ex.Message}】"); |
| | | } |
| | | return null; |
| | | } |
| | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | Console.WriteLine($"UpdatePosition 更新任务位置失败,任务号:【{taskNum}】,错误信息:【{ex.Message}】"); |
| | | QuartzLogHelper.LogError(Logger.None, $"UpdatePosition 更新任务位置失败,任务号:【{taskNum}】,错误信息:【{ex.Message}】", "UpdatePosition"); |
| | | } |
| | | return null; |
| | | } |