| | |
| | | using WIDESEAWCS_Core; |
| | | using WIDESEAWCS_Core.Helper; |
| | | using WIDESEAWCS_DTO.TaskInfo; |
| | | using WIDESEAWCS_IBasicInfoRepository; |
| | | using WIDESEAWCS_ITaskInfoService; |
| | | using WIDESEAWCS_Model.Models; |
| | | using WIDESEAWCS_QuartzJob; |
| | |
| | | namespace WIDESEAWCS_Tasks |
| | | { |
| | | [DisallowConcurrentExecution] |
| | | public class AGVJob : JobBase, IJob |
| | | public partial class AGVJob : JobBase, IJob |
| | | { |
| | | public readonly ITaskService _taskService; |
| | | private readonly ITaskExecuteDetailService _taskExecuteDetailService; |
| | | private readonly IRouterService _routerService; |
| | | private readonly IStationMangerRepository _stationMangerRepository; |
| | | private readonly IMapper _mapper; |
| | | |
| | | public AGVJob(ITaskService taskService, ITaskExecuteDetailService taskExecuteDetailService, IRouterService routerService, IMapper mapper) |
| | | public AGVJob(ITaskService taskService, ITaskExecuteDetailService taskExecuteDetailService, IRouterService routerService, IStationMangerRepository stationMangerRepository, IMapper mapper) |
| | | { |
| | | _taskService = taskService; |
| | | _taskExecuteDetailService = taskExecuteDetailService; |
| | | _routerService = routerService; |
| | | _stationMangerRepository = stationMangerRepository; |
| | | _mapper = mapper; |
| | | } |
| | | public Task Execute(IJobExecutionContext context) |
| | | { |
| | | try |
| | | { |
| | | List<Dt_Task> UpTasks = new List<Dt_Task>(); |
| | | var newTasks = _taskService.Db.Queryable<Dt_Task>().Where(x => x.TaskState == TaskStatusEnum.AGV_Execute.ObjToInt() || x.TaskState == TaskStatusEnum.New.ObjToInt()).ToList().OrderBy(x => x.Grade).ThenBy(x => x.CreateDate).ToList(); |
| | | foreach (var agvTask in newTasks) |
| | | { |
| | | AgvTaskDTO taskDTO = new AgvTaskDTO() |
| | | { |
| | | ReqCode = agvTask.TaskNum.ToString(), |
| | | TaskTyp = AgvTaskType(agvTask.TaskType, agvTask.DeviceCode), |
| | | PositionCodePath = new List<CodePath>() |
| | | { |
| | | new CodePath() |
| | | { |
| | | type="", |
| | | positionCode="" |
| | | }, |
| | | new CodePath() |
| | | { |
| | | type="", |
| | | positionCode="" |
| | | } |
| | | }, |
| | | PodTyp = agvTask.PalletType == 1 ? "XX" : "DD", |
| | | }; |
| | | WebResponseContent content = _taskService.AgvSendTask(taskDTO); |
| | | if (content.Status) |
| | | { |
| | | agvTask.TaskState = TaskStatusEnum.AGV_Execute.ObjToInt(); |
| | | UpTasks.Add(agvTask); |
| | | } |
| | | } |
| | | _taskService.UpdateData(UpTasks); |
| | | SendAGVTask(); |
| | | |
| | | SendAGVWaitToTask(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | Console.Out.WriteLine(nameof(AGVJob) + ":" + ex.Message); |
| | | } |
| | | return Task.CompletedTask; |
| | | } |
| | | |
| | | public string AgvTaskType(int TaskType, string DeviceCode) |
| | | { |
| | | switch (DeviceCode) |
| | | { |
| | | case "SC01-CSJ": |
| | | { |
| | | return TaskType == TaskTypeEnum.ProductionReturn.ObjToInt() ? "23" : "24"; |
| | | } |
| | | case "SC01-ZH": |
| | | { |
| | | if (TaskType == TaskTypeEnum.InboundXB.ObjToInt()) |
| | | return "20"; |
| | | else if (TaskType == TaskTypeEnum.InboundJT.ObjToInt()) |
| | | return "21"; |
| | | else return "22"; |
| | | } |
| | | default: |
| | | throw new NotImplementedException(); |
| | | } |
| | | } |
| | | } |
| | | } |