| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Reflection; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using WIDESEAWCS_Common; |
| | |
| | | using WIDESEAWCS_ITaskInfoService; |
| | | using WIDESEAWCS_Model.Models; |
| | | using WIDESEAWCS_QuartzJob; |
| | | using WIDESEAWCS_Tasks.HoisterJob; |
| | | |
| | | namespace WIDESEAWCS_Tasks |
| | | { |
| | |
| | | WriteInfo(nameof(GroundStationJob_CSJ), "è°åº¦é误,设å¤å¯¹è±¡ä¼ å¼ä¸ºnull"); |
| | | return Task.CompletedTask; |
| | | } |
| | | |
| | | List<string> deviceStations = device.DeviceProDTOs.Select(x => x.DeviceChildCode).ToList(); |
| | | List<Dt_StationManger> stationMangers = _stationMangerRepository.QueryData(x => x.StationDeviceCode == device.DeviceCode); |
| | | foreach (var item in stationMangers) |
| | | foreach (var item in stationMangers.Where(x => deviceStations.Contains(x.StationCode))) |
| | | { |
| | | bool isCanPut = device.GetValue<GroundStationDBName, bool>(GroundStationDBName.R_IsCanPut, item.StationCode); |
| | | bool isCanTake = device.GetValue<GroundStationDBName, bool>(GroundStationDBName.R_IsCanTake, item.StationCode); |
| | | bool putRequest = device.GetValue<GroundStationDBName, bool>(GroundStationDBName.W_PutRequest, item.StationCode); |
| | | bool putFinish = device.GetValue<GroundStationDBName, bool>(GroundStationDBName.W_PutFinish, item.StationCode); |
| | | bool takeRequest = device.GetValue<GroundStationDBName, bool>(GroundStationDBName.W_TakeRequest, item.StationCode); |
| | | bool takeFinish = device.GetValue<GroundStationDBName, bool>(GroundStationDBName.W_TakeFinish, item.StationCode); |
| | | |
| | | if (item.StationType == StationTypeEnum.StationType_OnlyOutbound.ObjToInt()) |
| | | try |
| | | { |
| | | Dt_Task task = _taskRepository.QueryFirst(x => x.DeviceCode == item.StackerCraneCode && x.TaskState == TaskStatusEnum.New.ObjToInt() && string.IsNullOrEmpty(x.NextAddress)); |
| | | if (task != null && isCanPut && !isCanTake && !putRequest && !putFinish && !takeRequest && !takeFinish) |
| | | bool isCanPut = device.GetValue<GroundStationDBName, bool>(GroundStationDBName.R_IsCanPut, item.StationCode); |
| | | bool isCanTake = device.GetValue<GroundStationDBName, bool>(GroundStationDBName.R_IsCanTake, item.StationCode); |
| | | bool putRequest = device.GetValue<GroundStationDBName, bool>(GroundStationDBName.W_PutRequest, item.StationCode); |
| | | bool putFinish = device.GetValue<GroundStationDBName, bool>(GroundStationDBName.W_PutFinish, item.StationCode); |
| | | bool takeRequest = device.GetValue<GroundStationDBName, bool>(GroundStationDBName.W_TakeRequest, item.StationCode); |
| | | bool takeFinish = device.GetValue<GroundStationDBName, bool>(GroundStationDBName.W_TakeFinish, item.StationCode); |
| | | |
| | | if (item.StationType == StationTypeEnum.StationType_OnlyOutbound.ObjToInt()) |
| | | { |
| | | string oldAddress = task.NextAddress; |
| | | int oldStatus = task.TaskState; |
| | | task.TaskState = TaskStatusEnum.SC_Execute.ObjToInt(); |
| | | task.NextAddress = item.StationCode; |
| | | _taskRepository.UpdateData(task); |
| | | _taskExecuteDetailService.AddTaskExecuteDetail(task.TaskNum, $"ç³»ç»èªå¨æµç¨,ç®æ å°åç±{oldAddress}åæ´ä¸º{task.NextAddress},ä»»å¡ç¶æç±{oldStatus}åæ´ä¸º{task.TaskState}"); |
| | | Dt_Task task = _taskRepository.QueryFirst(x => x.DeviceCode == item.StackerCraneCode && x.TaskState == TaskStatusEnum.New.ObjToInt() && string.IsNullOrEmpty(x.NextAddress)); |
| | | if (task != null && isCanPut && !isCanTake && !putRequest && !putFinish && !takeRequest && !takeFinish) |
| | | { |
| | | string oldAddress = task.NextAddress; |
| | | int oldStatus = task.TaskState; |
| | | task.TaskState = TaskStatusEnum.SC_Execute.ObjToInt(); |
| | | task.NextAddress = item.StationCode; |
| | | _taskRepository.UpdateData(task); |
| | | _taskExecuteDetailService.AddTaskExecuteDetail(task.TaskNum, $"ç³»ç»èªå¨æµç¨,ç®æ å°åç±{oldAddress}åæ´ä¸º{task.NextAddress},ä»»å¡ç¶æç±{oldStatus}åæ´ä¸º{task.TaskState}"); |
| | | } |
| | | } |
| | | if (item.StationType == StationTypeEnum.StationType_OnlyInbound.ObjToInt()) |
| | | { |
| | | Dt_Task task = _taskRepository.QueryFirst(x => x.TargetAddress == item.StackerCraneCode && x.TaskState == TaskStatusEnum.New.ObjToInt() && string.IsNullOrEmpty(x.NextAddress)); |
| | | if (task != null && isCanPut && !isCanTake && !putRequest && !putFinish && !takeRequest && !takeFinish) |
| | | { |
| | | string oldAddress = task.NextAddress; |
| | | int oldStatus = task.TaskState; |
| | | task.TaskState = TaskStatusEnum.SC_Execute.ObjToInt(); |
| | | task.NextAddress = item.StationCode; |
| | | _taskRepository.UpdateData(task); |
| | | _taskExecuteDetailService.AddTaskExecuteDetail(task.TaskNum, $"ç³»ç»èªå¨æµç¨,ç®æ å°åç±{oldAddress}åæ´ä¸º{task.NextAddress},ä»»å¡ç¶æç±{oldStatus}åæ´ä¸º{task.TaskState}"); |
| | | } |
| | | } |
| | | } |
| | | else if (item.StationType == StationTypeEnum.StationType_OnlyInbound.ObjToInt()) |
| | | catch (Exception ex) |
| | | { |
| | | Dt_Task task = _taskRepository.QueryFirst(x => x.TargetAddress == item.StackerCraneCode && x.TaskState == TaskStatusEnum.New.ObjToInt() && string.IsNullOrEmpty(x.NextAddress)); |
| | | if (task != null && isCanPut && !isCanTake && !putRequest && !putFinish && !takeRequest && !takeFinish) |
| | | WriteError(device.DeviceCode, $"{item}交äºé误", ex); |
| | | } |
| | | } |
| | | |
| | | foreach (var item in stationMangers.Where(x => !deviceStations.Contains(x.StationCode))) |
| | | { |
| | | try |
| | | { |
| | | Dt_Task task = _taskRepository.QueryFirst(x => x.TaskState == TaskStatusEnum.New.ObjToInt() && x.SourceAddress == item.StationCode && _taskService.TaskInboundTypes.Contains(x.TaskType)); |
| | | if (task != null) |
| | | { |
| | | string oldAddress = task.NextAddress; |
| | | int oldStatus = task.TaskState; |
| | | Dt_StationManger? stationManger = stationMangers.FirstOrDefault(x => x.StationCode == item.StationCode); |
| | | if (stationManger == null) |
| | | { |
| | | WriteInfo(item.StationName, $"æªæ¾å°å¯¹åºç«å°ä¿¡æ¯,设å¤ç¼å·:{item.StationCode},ä»»å¡å·:{task.TaskNum}"); |
| | | break; |
| | | } |
| | | string? locationCode = _taskService.RequestAssignLocation(task.TaskNum, stationManger.StackerCraneCode); |
| | | if (string.IsNullOrEmpty(locationCode)) |
| | | { |
| | | WriteInfo(item.StationName, $"请æ±åé
è´§ä½è¿åä¿¡æ¯é误,设å¤ç¼å·:{item.StationCode},ä»»å¡å·:{task.TaskNum}"); |
| | | break; |
| | | } |
| | | task.CurrentAddress = stationManger.StackerCraneStationCode; |
| | | task.TargetAddress = locationCode; |
| | | task.NextAddress = locationCode; |
| | | task.DeviceCode = stationManger.StackerCraneCode; |
| | | task.TaskState = TaskStatusEnum.SC_Execute.ObjToInt(); |
| | | task.NextAddress = item.StationCode; |
| | | _taskRepository.UpdateData(task); |
| | | _taskExecuteDetailService.AddTaskExecuteDetail(task.TaskNum, $"ç³»ç»èªå¨æµç¨,ç®æ å°åç±{oldAddress}åæ´ä¸º{task.NextAddress},ä»»å¡ç¶æç±{oldStatus}åæ´ä¸º{task.TaskState}"); |
| | | } |
| | | } |
| | | catch(Exception ex) |
| | | { |
| | | |
| | | } |
| | | } |
| | | } |
| | | catch (Exception ex) |