| | |
| | | using WIDESEAWCS_Core; |
| | | using WIDESEAWCS_Core.BaseServices; |
| | | using WIDESEAWCS_Core.Enums; |
| | | using WIDESEAWCS_DTO.TaskInfo; |
| | | using WIDESEAWCS_ITaskInfoRepository; |
| | | using WIDESEAWCS_ITaskInfoService; |
| | | using WIDESEAWCS_Model.Models; |
| | |
| | | public class TaskExecuteDetailService : ServiceBase<Dt_TaskExecuteDetail, ITaskExecuteDetailRepository>, ITaskExecuteDetailService |
| | | { |
| | | private readonly ITaskRepository _taskRepository; |
| | | private readonly ITask_HtyRepository _task_Hty; |
| | | |
| | | public TaskExecuteDetailService(ITaskExecuteDetailRepository BaseDal, ITaskRepository taskRepository) : base(BaseDal) |
| | | public TaskExecuteDetailService(ITaskExecuteDetailRepository BaseDal, ITaskRepository taskRepository,ITask_HtyRepository task_Hty) : base(BaseDal) |
| | | { |
| | | _taskRepository = taskRepository; |
| | | _task_Hty = task_Hty; |
| | | } |
| | | |
| | | public void AddTaskExecuteDetail(int taskId, string description = "") |
| | | { |
| | | 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; |
| | | bool isNormal = true; |
| | | Dt_Task task = _taskRepository.QueryFirst(x => x.TaskId == taskId); |
| | | if (task == null) return; |
| | | int taskNum = task.TaskNum; |
| | | int taskState = task.TaskState; |
| | | int TaskStateremark = task.RGVTaskType; //æ°å¢RGvä»»å¡ç±»å |
| | | |
| | | |
| | | 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) |
| | | { |
| | | string getstastr = GetEnumDescription(taskState); |
| | | string getrgvtasktyperema = GetEnumDescription2(TaskStateremark); |
| | | |
| | | } |
| | | |
| | | 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, |
| | | Roadway = task.Roadway, //æ°å¢æ§è¡è®¾å¤ |
| | | RGVTaskType = TaskStateremark, |
| | | TaskStateremark = getstastr, |
| | | RGVTaskTyperemark = getrgvtasktyperema |
| | | }; |
| | | BaseDal.AddData(taskExecuteDetail); |
| | | } |
| | | |
| | | public void AddTaskExecuteDetail(List<int> taskNums, string description = "") |
| | |
| | | int active = -1; |
| | | List<object> list = new(); |
| | | List<int> steps = new(); |
| | | Dt_Task task = _taskRepository.QueryFirst(x => x.TaskNum == taskNum); |
| | | |
| | | int TaskType = 0; |
| | | int TaskState = 0; |
| | | Dt_Task_hty task_h = null; |
| | | |
| | | Dt_Task task = _taskRepository.QueryData().Where(x=>x.TaskNum == taskNum).FirstOrDefault(); |
| | | if (task != null) |
| | | { |
| | | TaskType = task.TaskType; |
| | | TaskState = task.TaskState; |
| | | } |
| | | else if(task == null) |
| | | { |
| | | task_h = _task_Hty.QueryData().Where(x => x.TaskNum == taskNum).FirstOrDefault(); |
| | | TaskType = task_h.TaskType; |
| | | TaskState = task_h.TaskState; |
| | | } |
| | | else |
| | | { |
| | | return content.Error("ä»»å¡ä¸åå¨"); |
| | | } |
| | | |
| | | if (!int.TryParse(Enum.Parse<TaskOutboundTypeEnum>(task.TaskType.ToString()).ToString(), out int result)) |
| | | if (task != null || task_h != null) |
| | | { |
| | | |
| | | if (!int.TryParse(Enum.Parse<TaskOutboundTypeEnum>(TaskType.ToString()).ToString(), out int result)) |
| | | { |
| | | steps = Enum.GetValues(typeof(TaskOutStatusEnum)).Cast<int>().Where(x => x <= (int)TaskOutStatusEnum.OutFinish).ToList(); |
| | | |
| | |
| | | list.Add(obj); |
| | | } |
| | | } |
| | | else if (!int.TryParse(Enum.Parse<TaskInboundTypeEnum>(task.TaskType.ToString()).ToString(), out result)) |
| | | else if (!int.TryParse(Enum.Parse<TaskInboundTypeEnum>(TaskType.ToString()).ToString(), out result)) |
| | | { |
| | | steps = Enum.GetValues(typeof(TaskInStatusEnum)).Cast<int>().ToList(); |
| | | steps = Enum.GetValues(typeof(TaskInStatusEnum)).Cast<int>().Where(x => x <= (int)TaskInStatusEnum.InPending).ToList(); |
| | | foreach (var item in steps) |
| | | { |
| | | object obj; |
| | |
| | | list.Add(obj); |
| | | } |
| | | } |
| | | else if (!int.TryParse(Enum.Parse<TaskRelocationTypeEnum>(task.TaskType.ToString()).ToString(), out result)) |
| | | else if (!int.TryParse(Enum.Parse<TaskRelocationTypeEnum>(TaskType.ToString()).ToString(), out result)) |
| | | { |
| | | //todo è°ç¨WMSç§»åºå®æ |
| | | } |
| | | |
| | | |
| | | else |
| | | { |
| | | throw new Exception($"ä»»å¡ç±»åé误,æªæ¾å°è¯¥ä»»å¡ç±»å,ä»»å¡å·:ã{taskNum}ã,ä»»å¡ç±»å:ã{task.TaskType}ã"); |
| | | throw new Exception($"ä»»å¡ç±»åé误,æªæ¾å°è¯¥ä»»å¡ç±»å,ä»»å¡å·:ã{taskNum}ã,ä»»å¡ç±»å:ã{TaskType}ã"); |
| | | } |
| | | active = steps.IndexOf(task.TaskState) + 1; |
| | | active = steps.IndexOf(TaskState) + 1; |
| | | |
| | | } |
| | | |
| | | content = WebResponseContent.Instance.OK(data: new { active, list }); |
| | | string curradd = task.CurrentAddress; |
| | | string nextadd = task.NextAddress; |
| | | content = WebResponseContent.Instance.OK(data: new { active, list,curradd, nextadd }); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | |
| | | WebResponseContent content = new(); |
| | | try |
| | | { |
| | | Dt_Task task = _taskRepository.QueryFirst(x => x.TaskNum == taskNum); |
| | | //Dt_Task task = _taskRepository.QueryFirst(x => x.TaskNum == taskNum); |
| | | |
| | | |
| | | Dt_Task task = _taskRepository.QueryData().Where(x => x.TaskNum == taskNum).FirstOrDefault(); |
| | | |
| | | int TaskNum = 0; |
| | | |
| | | Dt_Task_hty task_h = null; |
| | | if (task != null) |
| | | { |
| | | List<Dt_TaskExecuteDetail> taskExecuteDetails = BaseDal.QueryData(x => x.TaskId == task.TaskId, new Dictionary<string, SqlSugar.OrderByType> { { nameof(Dt_TaskExecuteDetail.TaskDetailId), SqlSugar.OrderByType.Asc } }); |
| | | TaskNum = task.TaskNum; |
| | | } |
| | | else if (task == null) |
| | | { |
| | | task_h = _task_Hty.QueryData().Where(x => x.TaskNum == taskNum).FirstOrDefault(); |
| | | TaskNum = task_h.TaskNum; |
| | | } |
| | | else |
| | | { |
| | | return content.Error("ä»»å¡ä¸åå¨"); |
| | | } |
| | | |
| | | if (task != null || task_h != null) |
| | | { |
| | | List<Dt_TaskExecuteDetail> taskExecuteDetails = BaseDal.QueryData(x => x.TaskNum == TaskNum, new Dictionary<string, SqlSugar.OrderByType> { { nameof(Dt_TaskExecuteDetail.TaskDetailId), SqlSugar.OrderByType.Asc } }); |
| | | |
| | | content = WebResponseContent.Instance.OK(data: taskExecuteDetails); |
| | | } |
| | |
| | | } |
| | | return content; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | /// <summary> |
| | | /// ä»»å¡ç±»åæä¸¾ |
| | | /// </summary> |
| | | public string GetEnumDescription(int enumValue) |
| | | { |
| | | var enumType = typeof(TaskInStatusEnum); |
| | | var field = enumType.GetFields() |
| | | .FirstOrDefault(f => f.FieldType == enumType && |
| | | (int)f.GetValue(null) == enumValue); |
| | | |
| | | if (field != null) |
| | | { |
| | | var descriptionAttribute = field.GetCustomAttributes(typeof(DescriptionAttribute), false) |
| | | .FirstOrDefault() as DescriptionAttribute; |
| | | |
| | | return descriptionAttribute?.Description ?? field.Name; |
| | | } |
| | | |
| | | return string.Empty; |
| | | } |
| | | |
| | | public string GetEnumDescription2(int enumValue) |
| | | { |
| | | var enumType = typeof(RGVTaskTypeEnum); |
| | | var field = enumType.GetFields() |
| | | .FirstOrDefault(f => f.FieldType == enumType && |
| | | (int)f.GetValue(null) == enumValue); |
| | | |
| | | if (field != null) |
| | | { |
| | | var descriptionAttribute = field.GetCustomAttributes(typeof(DescriptionAttribute), false) |
| | | .FirstOrDefault() as DescriptionAttribute; |
| | | |
| | | return descriptionAttribute?.Description ?? field.Name; |
| | | } |
| | | |
| | | return string.Empty; |
| | | } |
| | | } |
| | | } |