| | |
| | | using Microsoft.AspNetCore.Components.Routing; |
| | | using HslCommunication; |
| | | using Newtonsoft.Json; |
| | | using Quartz; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Diagnostics.CodeAnalysis; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using WIDESEAWCS_Common.TaskEnum; |
| | | using WIDESEAWCS_Core.Enums; |
| | | using WIDESEAWCS_Core.Helper; |
| | | using WIDESEAWCS_DTO.MOM; |
| | | using WIDESEAWCS_IProcessRepository; |
| | | using WIDESEAWCS_ITaskInfoRepository; |
| | | using WIDESEAWCS_ITaskInfoService; |
| | | using WIDESEAWCS_Model; |
| | | using WIDESEAWCS_Model.Models; |
| | | using WIDESEAWCS_QuartzJob; |
| | | using WIDESEAWCS_QuartzJob.DeviceBase; |
| | |
| | | private readonly ITaskExecuteDetailService _taskExecuteDetailService; |
| | | private readonly ITaskRepository _taskRepository; |
| | | private readonly IRouterService _routerService; |
| | | private readonly IProcessRepository _processRepository; |
| | | |
| | | public CommonStackerCraneJob(ITaskService taskService, ITaskExecuteDetailService taskExecuteDetailService, ITaskRepository taskRepository, IRouterService routerService) |
| | | public CommonStackerCraneJob(ITaskService taskService, ITaskExecuteDetailService taskExecuteDetailService, ITaskRepository taskRepository, IRouterService routerService, IProcessRepository processRepository) |
| | | { |
| | | _taskService = taskService; |
| | | _taskExecuteDetailService = taskExecuteDetailService; |
| | | _taskRepository = taskRepository; |
| | | _routerService = routerService; |
| | | _processRepository = processRepository; |
| | | } |
| | | |
| | | public Task Execute(IJobExecutionContext context) |
| | | { |
| | | try |
| | | { |
| | | |
| | | // speStackerCrane.GetStackerCraneStatus<StackerCraneAutoStatus>(); |
| | | // speStackerCrane.GetStackerCraneStatus<StackerCraneWorkStatus>(); |
| | | // speStackerCrane.GetStackerCraneStatus<StackerCraneStatus>(); |
| | |
| | | CommonStackerCrane commonStackerCrane = (CommonStackerCrane)context.JobDetail.JobDataMap.Get("JobParams"); |
| | | if (commonStackerCrane != null) |
| | | { |
| | | Console.Out.WriteLine(commonStackerCrane.DeviceName); |
| | | //EqptAlive(commonStackerCrane); |
| | | //Console.Out.WriteLine(commonStackerCrane.DeviceName); |
| | | if (!commonStackerCrane.IsEventSubscribed) |
| | | { |
| | | commonStackerCrane.StackerCraneTaskCompletedEventHandler += CommonStackerCrane_StackerCraneTaskCompletedEventHandler;//订阅任务完成事件 |
| | |
| | | task = _taskService.QueryStackerCraneInTask(commonStackerCrane.DeviceCode); |
| | | } |
| | | } |
| | | else if (task == null) |
| | | { |
| | | task = _taskService.QueryStackerCraneInTask(commonStackerCrane.DeviceCode); |
| | | } |
| | | |
| | | return task; |
| | | } |
| | |
| | | if (device != null) |
| | | { |
| | | CommonConveyorLine conveyorLine = (CommonConveyorLine)device; |
| | | if (conveyorLine.IsOccupied(router.ChildPosi))//出库站台未被占用 |
| | | //if (conveyorLine.IsOccupied(router.ChildPosi))//出库站台未被占用 |
| | | { |
| | | return task; |
| | | } |
| | |
| | | stackerCraneTaskCommand.TaskNum = task.TaskNum; |
| | | stackerCraneTaskCommand.WorkType = 1; |
| | | stackerCraneTaskCommand.TrayType = 0; |
| | | stackerCraneTaskCommand.StartCommand = 1; |
| | | if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.InboundGroup)//判断是否是入库任务 |
| | | { |
| | | List<Dt_Router> routers = _routerService.QueryNextRoutes(task.CurrentAddress, task.Roadway); |
| | |
| | | } |
| | | return stackerCraneTaskCommand; |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 设备心跳 |
| | | /// </summary> |
| | | /// <param name="commonStackerCrane"></param> |
| | | public async void EqptAlive(CommonStackerCrane commonStackerCrane) |
| | | { |
| | | if (commonStackerCrane.StackerOnline) |
| | | { |
| | | BasicDto dto = new BasicDto |
| | | { |
| | | EmployeeNo = "T00001", |
| | | EquipmentCode = commonStackerCrane.DeviceCode, |
| | | RequestTime = DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss.fffZ"), |
| | | SessionId = Guid.NewGuid().ToString(), |
| | | Software = commonStackerCrane.DeviceName, |
| | | }; |
| | | var respone = await HttpHelper.PostAsync("http://ts-momapp01:12020/api/MachineIntegration/EqptAlive", dto.ToJsonString()); |
| | | if (respone != null) |
| | | { |
| | | var result = JsonConvert.DeserializeObject<ResponseEqptAliveDto>(respone); |
| | | if (result != null && result.Success) |
| | | { |
| | | if (result.KeyFlag == "99") |
| | | commonStackerCrane.StackerOnline = true; |
| | | else if (result.KeyFlag == "98") |
| | | commonStackerCrane.StackerOnline = false; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | } |