| | |
| | | 锘縰sing Microsoft.AspNetCore.Components.Routing; |
| | | using Newtonsoft.Json; |
| | | using Quartz; |
| | | using System; |
| | | using System.Collections.Generic; |
| | |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using WIDESEAWCS_Common.APIEnum; |
| | | using WIDESEAWCS_Common.TaskEnum; |
| | | using WIDESEAWCS_Core; |
| | | using WIDESEAWCS_Core.Caches; |
| | | using WIDESEAWCS_Core.Enums; |
| | | using WIDESEAWCS_Core.Helper; |
| | | using WIDESEAWCS_IBasicInfoRepository; |
| | |
| | | [DisallowConcurrentExecution] |
| | | public class StackerCraneJob_YM : JobBase, IJob |
| | | { |
| | | private readonly ICacheService _cacheService; |
| | | private readonly ITaskService _taskService; |
| | | private readonly ITaskExecuteDetailService _taskExecuteDetailService; |
| | | private readonly ITaskRepository _taskRepository; |
| | | private readonly IRouterService _routerService; |
| | | private readonly IStationMangerRepository _stationMangerRepository; |
| | | private List<Dt_ApiInfo> apiInfos; |
| | | |
| | | public StackerCraneJob_YM(ITaskService taskService, ITaskExecuteDetailService taskExecuteDetailService, ITaskRepository taskRepository, IRouterService routerService, IStationMangerRepository stationMangerRepository) |
| | | public StackerCraneJob_YM(ITaskService taskService, ICacheService cacheService, ITaskExecuteDetailService taskExecuteDetailService, ITaskRepository taskRepository, IRouterService routerService, IStationMangerRepository stationMangerRepository) |
| | | { |
| | | _cacheService = cacheService; |
| | | _taskService = taskService; |
| | | _taskExecuteDetailService = taskExecuteDetailService; |
| | | _taskRepository = taskRepository; |
| | | _routerService = routerService; |
| | | _stationMangerRepository = stationMangerRepository; |
| | | |
| | | string? apiInfoStr = _cacheService.Get("apiInfos"); |
| | | if (!string.IsNullOrEmpty(apiInfoStr)) |
| | | { |
| | | apiInfos = JsonConvert.DeserializeObject<List<Dt_ApiInfo>>(apiInfoStr); |
| | | if (apiInfos == null || apiInfos.Count == 0) |
| | | { |
| | | apiInfos = new List<Dt_ApiInfo>(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | public Task Execute(IJobExecutionContext context) |
| | |
| | | Dt_Task task = _taskRepository.QueryFirst(x => x.TaskNum == e.TaskNum); |
| | | if (task != null) |
| | | { |
| | | string? url = apiInfos.FirstOrDefault(x => x.ApiCode == APIEnum.FeedBackWMSTaskCompleted.ToString())?.ApiAddress; |
| | | if (string.IsNullOrEmpty(url)) |
| | | { |
| | | _taskExecuteDetailService.AddTaskExecuteDetail(e.TaskNum, $"鏈壘鍒板洖璋僕MS浠诲姟瀹屾垚鎺ュ彛"); |
| | | WriteInfo(commonStackerCrane.DeviceName, $"鏈壘鍒板洖璋僕MS浠诲姟瀹屾垚鎺ュ彛"); |
| | | return; |
| | | } |
| | | |
| | | HttpHelper.Post($"{url}?taskNum={e.TaskNum}", "");//todo 璋冪敤WMS浠诲姟瀹屾垚鏂规硶 |
| | | _taskExecuteDetailService.AddTaskExecuteDetail(e.TaskNum, $"绯荤粺鑷姩娴佺▼,浠诲姟瀹屾垚"); |
| | | _taskRepository.DeleteAndMoveIntoHty(task, OperateTypeEnum.鑷姩瀹屾垚); |
| | | HttpHelper.Post("", "");//todo 璋冪敤WMS浠诲姟瀹屾垚鏂规硶 |
| | | } |
| | | else |
| | | { |
| | |
| | | OtherDevice client = (OtherDevice)device; |
| | | if (client.GetValue<GroundStationDBName, bool>(GroundStationDBName.R_IsCanPut, stationManger.StationCode))//鍑哄簱绔欏彴鏈鍗犵敤 |
| | | { |
| | | task.TargetAddress = stationManger.StackerCraneStationCode; |
| | | task.NextAddress = stationManger.StackerCraneStationCode; |
| | | _taskRepository.UpdateData(task); |
| | | return task; |
| | | } |