| | |
| | | |
| | | namespace WIDESEAWCS_Tasks |
| | | { |
| | | /// <summary> |
| | | /// éç¨è¾é线ç«å°ä»»å¡ç±»ï¼ç¨äºå¤çè¾é线ç«å°çPLCä¿¡å·äº¤äºåä»»å¡ç®¡ç |
| | | /// </summary> |
| | | /// <remarks> |
| | | /// 1. å®ç°IJobæ¥å£ï¼ä½ä¸ºQuartz.NETç宿¶ä»»å¡ <br/> |
| | | /// 2. éè¿DisallowConcurrentExecutionç¹æ§é²æ¢å¹¶åæ§è¡ <br/> |
| | | /// 3. 主è¦åè½ï¼ <br/> |
| | | /// - çæ§PLCç«å°è¯·æ±ä¿¡å· <br/> |
| | | /// - å¤çä»»å¡éæ°çæé»è¾ <br/> |
| | | /// - æ´æ°ä»»å¡ç¶æ <br/> |
| | | /// - 设置PLCååºä¿¡å· |
| | | /// </remarks> |
| | | [DisallowConcurrentExecution] |
| | | public class CommonConveyorLineStationJob : JobBase, IJob |
| | | { |
| | |
| | | |
| | | private readonly ITaskRepository _taskRepository; |
| | | |
| | | public CommonConveyorLineStationJob(IMapper mapper, ITaskRepository taskRepository) |
| | | private readonly ITaskService _taskService; |
| | | |
| | | public CommonConveyorLineStationJob(IMapper mapper, ITaskRepository taskRepository, ITaskService taskService) |
| | | { |
| | | _mapper = mapper; |
| | | _taskRepository = taskRepository; |
| | | _taskService = taskService; |
| | | } |
| | | |
| | | |
| | | public Task Execute(IJobExecutionContext context) |
| | | { |
| | | bool flag = context.JobDetail.JobDataMap.TryGetValue("JobParams", out object? value); |
| | | if (flag && value != null && value is OtherDevice) |
| | | if (flag && value != null && value is OtherDevice otherDevice) |
| | | { |
| | | OtherDevice otherDevice = (OtherDevice)value; |
| | | try |
| | | { |
| | | List<string> deviceChildCodes = otherDevice.DeviceProDTOs.GroupBy(x => x.DeviceChildCode).Select(x => x.Key).ToList(); |
| | |
| | | { |
| | | bool request = otherDevice.GetValue<ConveyorLineStationDBName, bool>(ConveyorLineStationDBName.PLCStationRequest, deviceChildCodes[i]); //ç³è¯· |
| | | bool response = otherDevice.GetValue<ConveyorLineStationDBName, bool>(ConveyorLineStationDBName.PLCStationResponse, deviceChildCodes[i]); //åºç |
| | | |
| | | bool wcsResponse = otherDevice.GetValue<ConveyorLineStationDBName, bool>(ConveyorLineStationDBName.WCSStationResponse, deviceChildCodes[i]); //åºç |
| | | |
| | | if (request && !response && !wcsResponse) |
| | |
| | | Dt_Task task = _taskRepository.QueryFirst(x => x.TaskNum == taskNum); |
| | | if (task != null) |
| | | { |
| | | task.TaskState = TaskStatusEnum.Gantry_New.ObjToInt(); |
| | | _taskRepository.UpdateData(task); |
| | | if (task.TaskState == TaskStatusEnum.Gantry_BeReassign.ObjToInt()) |
| | | { |
| | | var (taskFlag, gTask, message) = _taskService.RegenerateTask(task, deviceChildCodes[i]); |
| | | if (!taskFlag || gTask == null) |
| | | { |
| | | otherDevice.SetValue(ConveyorLineStationDBName.WCSStationTarget, 8, deviceChildCodes[i]); |
| | | otherDevice.SetValue(ConveyorLineStationDBName.WCSStationResponse, true, deviceChildCodes[i]); |
| | | continue; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | task.TaskState = TaskStatusEnum.Gantry_New.ObjToInt(); |
| | | _taskRepository.UpdateData(task); |
| | | } |
| | | |
| | | otherDevice.SetValue(ConveyorLineStationDBName.WCSStationTarget, 0, deviceChildCodes[i]); |
| | | otherDevice.SetValue(ConveyorLineStationDBName.WCSStationResponse, true, deviceChildCodes[i]); |
| | | } |