using AutoMapper; using HslCommunication; using NetTaste; using Newtonsoft.Json; using Quartz; using SqlSugar; using System.Reflection; using System.Text; using System.Threading.Tasks; using WIDESEAWCS_BasicInfoRepository; using WIDESEAWCS_BasicInfoService; using WIDESEAWCS_Common; using WIDESEAWCS_Common.TaskEnum; using WIDESEAWCS_Core; using WIDESEAWCS_Core.Helper; using WIDESEAWCS_Core.HttpContextUser; using WIDESEAWCS_DTO.TaskInfo; using WIDESEAWCS_IBasicInfoRepository; using WIDESEAWCS_IBasicInfoService; using WIDESEAWCS_ISystemServices; using WIDESEAWCS_ITaskInfoRepository; using WIDESEAWCS_ITaskInfoService; using WIDESEAWCS_Model.Models; using WIDESEAWCS_QuartzJob; using WIDESEAWCS_QuartzJob.DeviceBase; using WIDESEAWCS_QuartzJob.DTO; using WIDESEAWCS_QuartzJob.Models; using WIDESEAWCS_QuartzJob.Repository; using WIDESEAWCS_QuartzJob.Service; using WIDESEAWCS_SignalR; using WIDESEAWCS_Tasks.ConveyorLineJob; using WIDESEAWCS_Tasks.ElevatorJob; using ICacheService = WIDESEAWCS_Core.Caches.ICacheService; namespace WIDESEAWCS_Tasks { [DisallowConcurrentExecution] public partial class CommonConveyorLineJob : JobBase, IJob { private readonly ITaskService _taskService; private readonly ITaskRepository _taskRepository; private readonly ITask_HtyRepository _task_HtyRepository; private readonly ITaskExecuteDetailService _taskExecuteDetailService; private readonly IRouterService _routerService; private readonly ISys_ConfigService _sys_ConfigService; private readonly IMapper _mapper; private readonly IDt_StationManagerService _stationManagerService; private readonly IDt_StationManagerRepository _stationManagerRepository; private readonly ICacheService _cacheService; private readonly INoticeService _noticeService; private readonly IDeviceInfoRepository _deviceInfoRepository; private static List? userTokenIds; private static List? userIds; public CommonConveyorLineJob(ITaskService taskService, ITaskExecuteDetailService taskExecuteDetailService, IRouterService routerService, IMapper mapper, ITaskRepository taskRepository,ISys_ConfigService sys_ConfigService, IDt_StationManagerService stationManagerService, IDt_StationManagerRepository stationManagerRepository, ICacheService cacheService, INoticeService noticeService, IDeviceInfoRepository deviceInfoRepository, ITask_HtyRepository task_HtyRepository) { _taskService = taskService; _taskExecuteDetailService = taskExecuteDetailService; _routerService = routerService; _mapper = mapper; _taskRepository = taskRepository; _sys_ConfigService = sys_ConfigService; _stationManagerService = stationManagerService; _stationManagerRepository = stationManagerRepository; _cacheService = cacheService; _noticeService = noticeService; _deviceInfoRepository = deviceInfoRepository; _task_HtyRepository = task_HtyRepository; } public async Task Execute(IJobExecutionContext context) { string jobName = context.JobDetail.Key.Name; try { // 从JobDataMap中获取传递的参数 CommonConveyorLine conveyorLine = (CommonConveyorLine)context.JobDetail.JobDataMap.Get("JobParams"); if (conveyorLine != null) { ConveyorLineTaskCommand conmmand = conveyorLine.ReadCustomer("LK001"); if (conmmand != null) { var structs = BitConverter.GetBytes(conmmand.InteractiveSignal).Reverse().ToArray().ToBoolArray(); if (structs[2]) { //var task = _taskRepository.QueryFirst(x => x.TaskNum == conmmand.TargetAddress); var task = _taskRepository.QueryFirst(x => x.TaskState == (int)TaskInStatusEnum.Line_InExecuting && x.TaskNum == conmmand.ConveyorLineTargetAddress); if (task != null) { task.TaskState = (int)TaskInStatusEnum.Line_InFinish; task.CurrentAddress = task.NextAddress; //获取WMS货位信息 task.NextAddress = task.TargetAddress; _taskRepository.UpdateData(task); } } if (structs[0]) { var task = _taskService.QueryRequestConveyorLineSignalTask(); if (task != null && task.AGVSign == "RequestPickUp") { if (conveyorLine.GetValue(ConveyorLineDBName.AllowPickUp, "LK001") == 1) { await _taskService.ContinueAgvTask(task.AGVTaskNum); task.AGVSign = ""; task.TaskState = (int)TaskOutStatusEnum.Line_OutFinish; _taskRepository.UpdateData(task); } } if (task != null && task.AGVSign == "RequestPut") { if (conveyorLine.GetValue(ConveyorLineDBName.AllowPut, "LK001") == 1) { await _taskService.ContinueAgvTask(task.AGVTaskNum); task.AGVSign = ""; _taskRepository.UpdateData(task); } } } } } } catch (Exception ex) { // 输出异常信息 Console.Out.WriteLine(nameof(CommonConveyorLineJob) + ":" + ex.ToString()); } return; } } }