| | |
| | | using WIDESEAWCS_Tasks.ConveyorLineJob; |
| | | using WIDESEAWCS_QuartzJob.Repository; |
| | | using Autofac.Core; |
| | | using WIDESEAWCS_DTO.TaskInfo; |
| | | using AutoMapper; |
| | | |
| | | namespace WIDESEAWCS_Tasks |
| | | { |
| | | [DisallowConcurrentExecution] |
| | | public class StackerCraneJob_BC : JobBase, IJob |
| | | { |
| | | private readonly IMapper _mapper; |
| | | private readonly ICacheService _cacheService; |
| | | private readonly ITaskService _taskService; |
| | | private readonly ITaskExecuteDetailService _taskExecuteDetailService; |
| | |
| | | private List<Dt_ApiInfo> apiInfos; |
| | | private readonly List<Dt_WarehouseDevice> warehouseDevices; |
| | | |
| | | public StackerCraneJob_BC(ITaskService taskService, ICacheService cacheService, ITaskExecuteDetailService taskExecuteDetailService, ITaskRepository taskRepository, IRouterService routerService, IStationMangerRepository stationMangerRepository, IRouterRepository routerRepository) |
| | | public StackerCraneJob_BC(IMapper mapper, ITaskService taskService, ICacheService cacheService, ITaskExecuteDetailService taskExecuteDetailService, ITaskRepository taskRepository, IRouterService routerService, IStationMangerRepository stationMangerRepository, IRouterRepository routerRepository) |
| | | { |
| | | _mapper = mapper; |
| | | _taskService = taskService; |
| | | _taskExecuteDetailService = taskExecuteDetailService; |
| | | _taskRepository = taskRepository; |
| | |
| | | { |
| | | try |
| | | { |
| | | Console.WriteLine(DateTime.Now); |
| | | //Console.WriteLine(DateTime.Now); |
| | | CommonStackerCrane commonStackerCrane = (CommonStackerCrane)context.JobDetail.JobDataMap.Get("JobParams"); |
| | | if (commonStackerCrane != null) |
| | | { |
| | |
| | | Dt_Router router = _routerRepository.QueryFirst(x => x.InOutType == task.TaskType && x.StartPosi == stationManger.StationCode); |
| | | if (router == null) |
| | | { |
| | | router = _routerRepository.QueryFirst(x=>x.ChildPosi == deviceCode && x.ChildPosiDeviceCode == stationManger.StationDeviceCode && x.NextPosi == stationManger.StationCode && x.InOutType == task.TaskType && x.IsEnd); |
| | | router = _routerRepository.QueryFirst(x => x.ChildPosi == deviceCode && x.ChildPosiDeviceCode == stationManger.StationDeviceCode && x.NextPosi == stationManger.StationCode && x.InOutType == task.TaskType && x.IsEnd); |
| | | if (router != null && router.IsEnd) |
| | | { |
| | | _taskService.TaskCompleted(taskNum); |
| | |
| | | |
| | | if (task != null && task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup) |
| | | { |
| | | //string? url = apiInfos.FirstOrDefault(x => x.ApiCode == APIEnum.WMSIsReloaction.ToString())?.ApiAddress; |
| | | //if (string.IsNullOrEmpty(url)) |
| | | //{ |
| | | // _taskExecuteDetailService.AddTaskExecuteDetail(task.TaskNum, $"鏈壘鍒癢MS绉诲簱鍒ゆ柇鎺ュ彛"); |
| | | // WriteError(commonStackerCrane.DeviceCode, $"鏈壘鍒癢MS绉诲簱鍒ゆ柇鎺ュ彛"); |
| | | // _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"鏈壘鍒癢MS绉诲簱鍒ゆ柇鎺ュ彛"); |
| | | // return null; |
| | | //} |
| | | //HttpHelper.Post($"{url}?taskNum={task.TaskNum}&locationCode={task.NextAddress}", "");//todo 璋冪敤WMS浠诲姟瀹屾垚鏂规硶 |
| | | string? url = apiInfos.FirstOrDefault(x => x.ApiCode == APIEnum.WMSIsReloaction.ToString())?.ApiAddress; |
| | | if (string.IsNullOrEmpty(url)) |
| | | { |
| | | _taskExecuteDetailService.AddTaskExecuteDetail(task.TaskNum, $"鏈壘鍒癢MS绉诲簱鍒ゆ柇鎺ュ彛"); |
| | | WriteError(commonStackerCrane.DeviceCode, $"鏈壘鍒癢MS绉诲簱鍒ゆ柇鎺ュ彛"); |
| | | _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"鏈壘鍒癢MS绉诲簱鍒ゆ柇鎺ュ彛"); |
| | | return null; |
| | | } |
| | | string response = HttpHelper.Post($"{url}?taskNum={task.TaskNum}&locationCode={task.CurrentAddress}", "");//todo 璋冪敤WMS浠诲姟瀹屾垚鏂规硶 |
| | | if (string.IsNullOrEmpty(response)) |
| | | { |
| | | _taskExecuteDetailService.AddTaskExecuteDetail(task.TaskNum, $"绉诲簱鎺ュ彛璋冪敤閿欒"); |
| | | WriteError(commonStackerCrane.DeviceCode, $"绉诲簱鎺ュ彛璋冪敤閿欒"); |
| | | _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"绉诲簱鎺ュ彛璋冪敤閿欒"); |
| | | return null; |
| | | } |
| | | WebResponseContent? responseContent = JsonConvert.DeserializeObject<WebResponseContent>(response); |
| | | if (responseContent == null || !responseContent.Status) |
| | | { |
| | | _taskExecuteDetailService.AddTaskExecuteDetail(task.TaskNum, $"绉诲簱鎺ュ彛璋冪敤閿欒"); |
| | | WriteError(commonStackerCrane.DeviceCode, $"绉诲簱鎺ュ彛璋冪敤閿欒"); |
| | | _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"绉诲簱鎺ュ彛璋冪敤閿欒"); |
| | | return null; |
| | | } |
| | | WMSTaskDTO? taskDTO = JsonConvert.DeserializeObject<WMSTaskDTO>(responseContent.Data.Serialize()); |
| | | if (taskDTO == null) |
| | | { |
| | | _taskExecuteDetailService.AddTaskExecuteDetail(task.TaskNum, $"绉诲簱鎺ュ彛璋冪敤閿欒"); |
| | | WriteError(commonStackerCrane.DeviceCode, $"绉诲簱鎺ュ彛璋冪敤閿欒"); |
| | | _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"绉诲簱鎺ュ彛璋冪敤閿欒"); |
| | | return null; |
| | | |
| | | } |
| | | if (task.TaskNum == taskDTO.TaskNum) |
| | | { |
| | | return task; |
| | | } |
| | | else |
| | | { |
| | | Dt_Task reloTask = _mapper.Map<Dt_Task>(taskDTO); |
| | | reloTask.TaskState = TaskStatusEnum.SC_Execute.ObjToInt(); |
| | | reloTask.CurrentAddress = taskDTO.SourceAddress; |
| | | reloTask.NextAddress = taskDTO.TargetAddress; |
| | | reloTask.DeviceCode = task.DeviceCode; |
| | | reloTask.TaskType = TaskTypeEnum.Relocation.ObjToInt(); |
| | | int taskId = _taskRepository.AddData(reloTask); |
| | | reloTask.TaskId = taskId; |
| | | return reloTask; |
| | | |
| | | } |
| | | } |
| | | |
| | | return task; |
| | |
| | | /// <returns>濡傛灉鏈鍗犵敤锛岃繑鍥炰紶鍏ョ殑浠诲姟淇℃伅锛屽惁鍒欙紝杩斿洖null</returns> |
| | | private Dt_Task? OutTaskStationIsOccupied([NotNull] Dt_Task task) |
| | | { |
| | | Dt_StationManger? stationManger = _stationMangerRepository.QueryFirst(x => x.StationCode == task.NextAddress && x.StackerCraneCode == task.DeviceCode); |
| | | Dt_StationManger? stationManger = _stationMangerRepository.QueryFirst(x => (x.StationCode == task.NextAddress || x.StackerCraneStationCode == task.NextAddress) && x.StackerCraneCode == task.DeviceCode); |
| | | if (stationManger != null) |
| | | { |
| | | IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == stationManger.StationDeviceCode); |