| | |
| | | using System.Reflection; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using WIDESEAWCS_Common.TaskEnum; |
| | | using WIDESEAWCS_Core; |
| | | using WIDESEAWCS_Core.BaseServices; |
| | | using WIDESEAWCS_Core.Enums; |
| | |
| | | { |
| | | try |
| | | { |
| | | bool isNormal = true; |
| | | Dt_Task task = _taskRepository.QueryFirst(x => x.TaskId == taskId); |
| | | if (task == null) return; |
| | | int taskNum = task.TaskNum; |
| | | int taskState = task.TaskState; |
| | | |
| | | if (!int.TryParse(Enum.Parse<TaskOutStatusEnum>(taskState.ToString()).ToString(), out int result)) |
| | | { |
| | | if ((int)(TaskOutStatusEnum)result > (int)TaskOutStatusEnum.OutFinish) |
| | | isNormal = false; |
| | | } |
| | | else if (!int.TryParse(Enum.Parse<TaskInStatusEnum>(taskState.ToString()).ToString(), out result)) |
| | | { |
| | | if ((int)(TaskInStatusEnum)result > (int)TaskInStatusEnum.InFinish) |
| | | isNormal = false; |
| | | } |
| | | Dt_TaskExecuteDetail taskExecuteDetail = new() |
| | | { |
| | | IsManual = App.User.UserId > 0, |
| | | IsNormal = isNormal, |
| | | TaskNum = taskNum, |
| | | TaskId = taskId, |
| | | TaskState = taskState, |
| | | Description = description, |
| | | CurrentAddress = task.CurrentAddress, |
| | | NextAddress = task.NextAddress, |
| | | }; |
| | | BaseDal.AddData(taskExecuteDetail); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | |
| | | List<Dt_TaskExecuteDetail> taskExecuteDetails = new List<Dt_TaskExecuteDetail>(); |
| | | foreach (var item in taskNums) |
| | | { |
| | | bool isNormal = true; |
| | | Dt_Task task = _taskRepository.QueryFirst(x => x.TaskNum == item); |
| | | if (task == null) return; |
| | | int taskNum = task.TaskNum; |
| | | int taskState = task.TaskState; |
| | | |
| | | if (!int.TryParse(Enum.Parse<TaskOutStatusEnum>(taskState.ToString()).ToString(), out int result)) |
| | | { |
| | | if ((int)(TaskOutStatusEnum)result > (int)TaskOutStatusEnum.OutFinish) |
| | | isNormal = false; |
| | | } |
| | | else if (!int.TryParse(Enum.Parse<TaskInStatusEnum>(taskState.ToString()).ToString(), out result)) |
| | | { |
| | | if ((int)(TaskInStatusEnum)result > (int)TaskInStatusEnum.InFinish) |
| | | isNormal = false; |
| | | } |
| | | Dt_TaskExecuteDetail taskExecuteDetail = new() |
| | | { |
| | | IsManual = App.User.UserId > 0, |
| | | IsNormal = isNormal, |
| | | TaskNum = taskNum, |
| | | TaskId = task.TaskId, |
| | | TaskState = taskState, |
| | | Description = description, |
| | | CurrentAddress = task.CurrentAddress, |
| | | NextAddress = task.NextAddress, |
| | | }; |
| | | taskExecuteDetails.Add(taskExecuteDetail); |
| | | } |
| | | |
| | | BaseDal.AddData(taskExecuteDetails); |
| | |
| | | WebResponseContent content = new(); |
| | | try |
| | | { |
| | | int active = -1; |
| | | List<object> list = new(); |
| | | List<int> steps = new(); |
| | | Dt_Task task = _taskRepository.QueryFirst(x => x.TaskNum == taskNum); |
| | | if (task != null) |
| | | { |
| | | |
| | | if (!int.TryParse(Enum.Parse<TaskOutboundTypeEnum>(task.TaskType.ToString()).ToString(), out int result)) |
| | | { |
| | | steps = Enum.GetValues(typeof(TaskOutStatusEnum)).Cast<int>().Where(x => x <= (int)TaskOutStatusEnum.OutFinish).ToList(); |
| | | |
| | | foreach (var item in steps) |
| | | { |
| | | object obj; |
| | | FieldInfo? fieldInfo = typeof(TaskOutStatusEnum).GetField(((TaskOutStatusEnum)item).ToString()); |
| | | DescriptionAttribute? descriptionAttribute = fieldInfo.GetCustomAttribute<DescriptionAttribute>(); |
| | | if (descriptionAttribute != null) |
| | | { |
| | | obj = new { title = item, description = descriptionAttribute.Description }; |
| | | } |
| | | else |
| | | { |
| | | obj = new { title = item, description = ((TaskOutStatusEnum)item).ToString() }; |
| | | } |
| | | list.Add(obj); |
| | | } |
| | | } |
| | | else if (!int.TryParse(Enum.Parse<TaskInboundTypeEnum>(task.TaskType.ToString()).ToString(), out result)) |
| | | { |
| | | steps = Enum.GetValues(typeof(TaskInStatusEnum)).Cast<int>().Where(x => x <= (int)TaskInStatusEnum.InFinish).ToList(); |
| | | foreach (var item in steps) |
| | | { |
| | | object obj; |
| | | FieldInfo? fieldInfo = typeof(TaskInStatusEnum).GetField(((TaskInStatusEnum)item).ToString()); |
| | | DescriptionAttribute? descriptionAttribute = fieldInfo.GetCustomAttribute<DescriptionAttribute>(); |
| | | if (descriptionAttribute != null) |
| | | { |
| | | obj = new { title = item, description = descriptionAttribute.Description }; |
| | | } |
| | | else |
| | | { |
| | | obj = new { title = item, description = ((TaskInStatusEnum)item).ToString() }; |
| | | } |
| | | list.Add(obj); |
| | | } |
| | | } |
| | | else if (!int.TryParse(Enum.Parse<TaskRelocationTypeEnum>(task.TaskType.ToString()).ToString(), out result)) |
| | | { |
| | | //todo è°ç¨WMSç§»åºå®æ |
| | | } |
| | | else if (!int.TryParse(Enum.Parse<TaskOtherTypeEnum>(task.TaskType.ToString()).ToString(), out result)) |
| | | { |
| | | |
| | | } |
| | | else |
| | | { |
| | | throw new Exception($"ä»»å¡ç±»åé误,æªæ¾å°è¯¥ä»»å¡ç±»å,ä»»å¡å·:ã{taskNum}ã,ä»»å¡ç±»å:ã{task.TaskType}ã"); |
| | | } |
| | | active = steps.IndexOf(task.TaskState) + 1; |
| | | |
| | | } |
| | | |
| | | content = WebResponseContent.Instance.OK(data: new { active, list }); |
| | | } |
| | | catch (Exception ex) |
| | | { |