| | |
| | | using WIDESEAWCS_Common; |
| | | using WIDESEAWCS_IBasicInfoRepository; |
| | | using WIDESEAWCS_BasicInfoService; |
| | | using WIDESEAWCS_Model.BasicInfo; |
| | | using WIDESEAWCS_Tasks.RGVJob; |
| | | using WIDESEAWCS_Tasks.ConveyorLineJob; |
| | | using WIDESEAWCS_TaskInfoRepository; |
| | | using static Microsoft.EntityFrameworkCore.DbLoggerCategory.Database; |
| | | |
| | | namespace WIDESEAWCS_Tasks |
| | | { |
| | |
| | | CommonStackerCrane commonStackerCrane = (CommonStackerCrane)context.JobDetail.JobDataMap.Get("JobParams"); |
| | | if (commonStackerCrane != null) |
| | | { |
| | | if (!commonStackerCrane.IsEventSubscribed) |
| | | if (commonStackerCrane.GetValue<StackerCraneDBName, bool>(StackerCraneDBName.TaskCompleted)) |
| | | { |
| | | commonStackerCrane.StackerCraneTaskCompletedEventHandler += CommonStackerCrane_StackerCraneTaskCompletedEventHandler;//订é
ä»»å¡å®æäºä»¶ |
| | | var x = commonStackerCrane.GetValue<StackerCraneDBName, short>(StackerCraneDBName.CurrentTaskNum); |
| | | StackerCraneTaskFinish(commonStackerCrane, commonStackerCrane.GetValue<StackerCraneDBName, short>(StackerCraneDBName.CurrentTaskNum)); |
| | | } |
| | | |
| | | commonStackerCrane.CheckStackerCraneTaskCompleted();//鲿¢ä»»å¡å®æäºä»¶çæµè¶
æ¶ï¼åæå¨è§¦å䏿¬¡ |
| | | |
| | | |
| | | if (commonStackerCrane.GetValue<StackerCraneDBName, bool>(StackerCraneDBName.Automatic) && !commonStackerCrane.GetValue<StackerCraneDBName, bool>(StackerCraneDBName.Fault) && !commonStackerCrane.GetValue<StackerCraneDBName, bool>(StackerCraneDBName.Running)) |
| | | { |
| | |
| | | var userTokenIds = tokenInfos?.Select(x => x.Token_ID).ToList(); |
| | | var userIds = tokenInfos?.Select(x => x.UserId).ToList(); |
| | | |
| | | string StackerCraneAutoStatus(bool AutoStatus) => AutoStatus switch |
| | | { |
| | | true => "èæºæ¨¡å¼", |
| | | false => "åæºæ¨¡å¼", |
| | | }; |
| | | string StackerCraneWorkStatus(bool WorkStatus) => WorkStatus switch |
| | | { |
| | | true => "è¿è¡ä¸", |
| | | false => "å¾
æº", |
| | | }; |
| | | string StackerCraneStatus(bool Status) => Status switch |
| | | { |
| | | true => "æ
é", |
| | | false => "æ£å¸¸", |
| | | }; |
| | | string StackerCraneAlarm(int alarm) => alarm switch |
| | | { |
| | | 0 => "æä»¤æå°åé误", |
| | | 1 => "æ¥å", |
| | | 2 => "å
éè®¯ä¸æ", |
| | | 3 => "ç»æå¤±è", |
| | | 4 => "è¡èµ°å颿
é", |
| | | 5 => "è¡èµ°æé触å", |
| | | 6 => "è¡èµ°è¿è¡è¶
æ¶", |
| | | 7 => "æåå颿
é", |
| | | 8 => "æåæé触å", |
| | | 9 => "æåè¿è¡è¶
æ¶", |
| | | 10 => "载货å°è¶
è½½", |
| | | 11 => "è½½è´§å°æ¬ è½½ï¼æ¾ç»³)", |
| | | 12 => "载货å°å¤±é", |
| | | 13 => "è´§åå颿¥è¦", |
| | | 14 => "è´§åè¿è¡è¶
æ¶", |
| | | 15 => "è´§åæé触å", |
| | | 16 => "è´§åä¸å±
ä¸", |
| | | 17 => "左侧è¶
é«", |
| | | 18 => "å³ä¾§è¶
é«", |
| | | 19 => "左侧è¶
宽", |
| | | 20 => "å³ä¾§è¶
宽", |
| | | 21 => "å·¦è¶
åº", |
| | | 22 => "å³è¶
åº", |
| | | 23 => "åè´§æ¶è½½è´§å°æè´§", |
| | | 24 => "åè´§åè½½è´§å°æ è´§", |
| | | 25 => "åæ·±è´§ä½æ¶æµ
è´§ä½æè´§", |
| | | 26 => "æ¾è´§æ¶è½½è´§å°æ è´§", |
| | | 27 => "æ¾è´§æ¶è´§æ¶æè´§", |
| | | 28 => "æ¾è´§åè½½è´§å°æè´§", |
| | | 29 => "æ¾æ·±è´§æ¶æµ
è´§ä½æè´§", |
| | | 30 => "", |
| | | 31 => "", |
| | | }; |
| | | object obj = new |
| | | { |
| | | Automatic = commonStackerCrane.GetValue<StackerCraneDBName, bool>(StackerCraneDBName.Automatic), |
| | | Fault = commonStackerCrane.GetValue<StackerCraneDBName, bool>(StackerCraneDBName.Fault), |
| | | Running = commonStackerCrane.GetValue<StackerCraneDBName, bool>(StackerCraneDBName.Running), |
| | | commonStackerCrane.StackerCraneAutoStatusDes, |
| | | commonStackerCrane.StackerCraneWorkStatusDes, |
| | | Automatic = StackerCraneAutoStatus(commonStackerCrane.GetValue<StackerCraneDBName, bool>(StackerCraneDBName.Automatic)), |
| | | Fault = StackerCraneStatus(commonStackerCrane.GetValue<StackerCraneDBName, bool>(StackerCraneDBName.Fault)), |
| | | Running = StackerCraneWorkStatus(commonStackerCrane.GetValue<StackerCraneDBName, bool>(StackerCraneDBName.Running)), |
| | | CurrentColumn = Convert.ToInt32(commonStackerCrane.GetValue<StackerCraneDBName, byte>(StackerCraneDBName.CurrentColumn)), |
| | | CurrentLayer = Convert.ToInt32(commonStackerCrane.GetValue<StackerCraneDBName, byte>(StackerCraneDBName.CurrentLayer)), |
| | | LevelPoint = commonStackerCrane.GetValue<StackerCraneDBName, int>(StackerCraneDBName.LevelPoint), |
| | | CurrentTaskNum = commonStackerCrane.GetValue<StackerCraneDBName, short>(StackerCraneDBName.CurrentTaskNum), |
| | | //StackerAlarm = StackerCraneAlarm(commonStackerCrane.GetValue<StackerCraneDBName, int>(StackerCraneDBName.StackerAlarm)), |
| | | |
| | | commonStackerCrane.DeviceCode, |
| | | commonStackerCrane.DeviceName, |
| | | commonStackerCrane.CurrentTaskNum, |
| | | commonStackerCrane.LastTaskNum, |
| | | }; |
| | | _noticeService.StackerData(userIds?.FirstOrDefault(), userTokenIds, new { commonStackerCrane.DeviceName, data = obj }); |
| | | |
| | |
| | | str = $"{commonStackerCrane.DeviceName}ãWMS|WCSä»»å¡å®æï¼ã{content.Status}ã,å åæºå®æä¿¡å·åå
¥ï¼ã{isWorkType}ã,ä»»å¡å·ï¼ã{e.TaskNum}ãæ¶é´ã{DateTime.Now}ã"; |
| | | WriteInfo(commonStackerCrane.DeviceName, str); |
| | | ConsoleHelper.WriteColorLine(str, ConsoleColor.Blue); |
| | | } |
| | | } |
| | | } |
| | | |
| | | public void StackerCraneTaskFinish(CommonStackerCrane commonStackerCrane, int TaskNum) |
| | | { |
| | | if (commonStackerCrane != null) |
| | | { |
| | | var task = _taskRepository.QueryFirst(x => x.TaskNum == TaskNum); |
| | | if (task != null) |
| | | { |
| | | if (task.TaskType == (int)TaskOutboundTypeEnum.Outbound) |
| | | { |
| | | if (Convert.ToInt32(task.TargetAddress) > 1999 && Convert.ToInt32(task.TargetAddress) < 3000) |
| | | { |
| | | |
| | | Dt_StationManager stationManager = _stationManagerRepository.QueryFirst(x => x.Roadway == task.Roadway && x.stationChildCode == task.TargetAddress); |
| | | if (stationManager != null) |
| | | { |
| | | IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == stationManager.stationPLC); |
| | | if (device != null) |
| | | { |
| | | CommonConveyorLine conveyorLine = (CommonConveyorLine)device; |
| | | |
| | | var InteractiveSignal = conveyorLine.GetValue<ConveyorLineDBName, byte>(ConveyorLineDBName.InteractiveSignal, stationManager.stationChildCode); |
| | | |
| | | var structs = BitConverter.GetBytes(InteractiveSignal).ToArray().ToBoolArray(); |
| | | if (structs[2]) |
| | | { |
| | | conveyorLine.SetValue(ConveyorLineDBName.WriteConveyorLineTargetAddress, Convert.ToInt16(stationManager.stationNextChildCode), stationManager.stationChildCode); |
| | | Thread.Sleep(100); |
| | | conveyorLine.SetValue(ConveyorLineDBName.WriteConveyorLineTaskNum, Convert.ToInt16(task.TaskNum), stationManager.stationChildCode); |
| | | Thread.Sleep(100); |
| | | conveyorLine.SetValue(ConveyorLineDBName.WriteInteractiveSignal, Convert.ToSByte(2), stationManager.stationChildCode); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | var content = _taskService.StackCraneTaskCompleted(TaskNum); |
| | | } |
| | | } |
| | | } |
| | |
| | | /// <returns>妿æªè¢«å ç¨ï¼è¿åä¼ å
¥çä»»å¡ä¿¡æ¯ï¼å¦åï¼è¿ånull</returns> |
| | | private Dt_Task? OutTaskStationIsOccupied([NotNull] Dt_Task task) |
| | | { |
| | | var stationinfo = _stationManagerRepository.QueryFirst(x => x.stationLocation == task.TargetAddress && x.Roadway == task.Roadway); |
| | | var stationinfo = _stationManagerRepository.QueryFirst(x => x.stationChildCode==task.NextAddress && x.Roadway == task.Roadway); |
| | | IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == stationinfo.stationPLC); |
| | | if (device != null) |
| | | { |
| | | CommonConveyorLine_After conveyorLine = (CommonConveyorLine_After)device; |
| | | if (conveyorLine.IsOccupied(stationinfo.stationChildCode))//åºåºç«å°æªè¢«å ç¨ |
| | | CommonConveyorLine conveyorLine = (CommonConveyorLine)device; |
| | | if (conveyorLine.IsOccupiedx(stationinfo.stationChildCode))//åºåºç«å°æªè¢«å ç¨ |
| | | { |
| | | return task; |
| | | } |
| | |
| | | { |
| | | StackerCraneTaskCommand stackerCraneTaskCommand = new StackerCraneTaskCommand(); |
| | | |
| | | stackerCraneTaskCommand.TaskNum = (byte)Convert.ToSByte(task.TaskNum); |
| | | stackerCraneTaskCommand.WorkType = 1; |
| | | stackerCraneTaskCommand.TaskNum = (short)Convert.ToInt16(task.TaskNum); |
| | | if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.InboundGroup)//夿æ¯å¦æ¯å
¥åºä»»å¡ |
| | | { |
| | | |
| | | List<Dt_Router> routers = _routerService.QueryNextRoutes(task.CurrentAddress, task.Roadway); |
| | | if (routers.Count > 0) |
| | | Dt_StationManager stationManager = _stationManagerRepository.QueryFirst(x => x.Roadway == task.Roadway && x.stationChildCode == task.CurrentAddress); |
| | | if (stationManager != null) |
| | | { |
| | | stackerCraneTaskCommand.StartRow = (byte)Convert.ToSByte(Convert.ToInt16(routers.FirstOrDefault().SrmRow)); |
| | | stackerCraneTaskCommand.StartColumn = (byte)Convert.ToSByte(routers.FirstOrDefault().SrmColumn); |
| | | stackerCraneTaskCommand.StartLayer = (byte)Convert.ToSByte(routers.FirstOrDefault().SrmLayer); |
| | | stackerCraneTaskCommand.WorkType = (byte)Convert.ToSByte(17); |
| | | string[] sourceCodes = stationManager.stationLocation.Split("-"); |
| | | if (sourceCodes.Length == 3) |
| | | { |
| | | stackerCraneTaskCommand.StartRow = (byte)Convert.ToSByte(sourceCodes[0]); |
| | | stackerCraneTaskCommand.StartColumn = (byte)Convert.ToSByte(sourceCodes[1]); |
| | | stackerCraneTaskCommand.StartLayer = (byte)Convert.ToSByte(sourceCodes[2]); |
| | | } |
| | | else |
| | | { |
| | | //æ°æ®é
ç½®é误 |
| | | _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"å
¥åºä»»å¡ç»ç¹é误ï¼èµ·ç¹ï¼ã{task.NextAddress}ã"); |
| | | return null; |
| | | } |
| | | |
| | | string[] targetCodes = task.NextAddress.Split("-"); |
| | | string[] targetCodes = task.TargetAddress.Split("-"); |
| | | if (targetCodes.Length == 3) |
| | | { |
| | | stackerCraneTaskCommand.EndRow = (byte)Convert.ToSByte(Convert.ToInt16(targetCodes[0]) % 2 != 0 ? (short)1 : (short)2); |
| | | stackerCraneTaskCommand.EndRow = (byte)Convert.ToSByte(targetCodes[0]); |
| | | stackerCraneTaskCommand.EndColumn = (byte)Convert.ToSByte(targetCodes[1]); |
| | | stackerCraneTaskCommand.EndLayer = (byte)Convert.ToSByte(targetCodes[2]); |
| | | } |
| | |
| | | } |
| | | else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup) |
| | | { |
| | | |
| | | List<Dt_Router> routers = _routerService.QueryNextRoutes(task.Roadway, task.TargetAddress); |
| | | if (routers.Count > 0) |
| | | stackerCraneTaskCommand.WorkType = (byte)Convert.ToSByte(18); |
| | | Dt_StationManager stationManager = _stationManagerRepository.QueryFirst(x => x.Roadway == task.Roadway && x.stationChildCode == task.NextAddress); |
| | | if (stationManager != null) |
| | | { |
| | | stackerCraneTaskCommand.EndRow = (byte)Convert.ToSByte(routers.FirstOrDefault().SrmRow); |
| | | stackerCraneTaskCommand.EndColumn = (byte)Convert.ToSByte(routers.FirstOrDefault().SrmColumn); |
| | | stackerCraneTaskCommand.EndLayer = (byte)Convert.ToSByte(routers.FirstOrDefault().SrmLayer); |
| | | |
| | | string[] sourceCodes = task.CurrentAddress.Split("-"); |
| | | if (sourceCodes.Length == 3) |
| | | { |
| | | stackerCraneTaskCommand.StartRow = (byte)Convert.ToSByte(Convert.ToInt16(sourceCodes[0]) % 2 != 0 ? (short)1 : (short)2); |
| | | stackerCraneTaskCommand.StartRow = (byte)Convert.ToSByte(sourceCodes[0]); |
| | | stackerCraneTaskCommand.StartColumn = (byte)Convert.ToSByte(sourceCodes[1]); |
| | | stackerCraneTaskCommand.StartLayer = (byte)Convert.ToSByte(sourceCodes[2]); |
| | | } |
| | | else |
| | | { |
| | | //æ°æ®é
ç½®é误 |
| | | _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"åºåºä»»å¡èµ·ç¹é误ï¼èµ·ç¹ï¼ã{task.CurrentAddress}ã"); |
| | | return null; |
| | | } |
| | | string[] targetCodes = stationManager.stationLocation.Split("-"); |
| | | if (targetCodes.Length == 3) |
| | | { |
| | | stackerCraneTaskCommand.EndRow = (byte)Convert.ToSByte(targetCodes[0]); |
| | | stackerCraneTaskCommand.EndColumn = (byte)Convert.ToSByte(targetCodes[1]); |
| | | stackerCraneTaskCommand.EndLayer = (byte)Convert.ToSByte(targetCodes[2]); |
| | | } |
| | | else |
| | | { |
| | |
| | | } |
| | | else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.RelocationGroup) |
| | | { |
| | | string[] targetCodes = task.NextAddress.Split("-"); |
| | | if (targetCodes.Length == 3) |
| | | { |
| | | stackerCraneTaskCommand.EndRow = (byte)Convert.ToSByte(Convert.ToInt16(targetCodes[0]) % 2 != 0 ? (short)1 : (short)2); |
| | | stackerCraneTaskCommand.EndColumn = (byte)Convert.ToSByte(targetCodes[1]); |
| | | stackerCraneTaskCommand.EndLayer = (byte)Convert.ToSByte(targetCodes[2]); |
| | | } |
| | | else |
| | | { |
| | | //æ°æ®é
ç½®é误 |
| | | _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"ç§»åºä»»å¡ç»ç¹é误ï¼èµ·ç¹ï¼ã{task.NextAddress}ã"); |
| | | return null; |
| | | } |
| | | string[] sourceCodes = task.CurrentAddress.Split("-"); |
| | | stackerCraneTaskCommand.WorkType = (byte)Convert.ToSByte(20); |
| | | string[] sourceCodes = task.SourceAddress.Split("-"); |
| | | if (sourceCodes.Length == 3) |
| | | { |
| | | stackerCraneTaskCommand.StartRow = (byte)Convert.ToSByte(Convert.ToInt16(sourceCodes[0]) % 2 != 0 ? (short)1 : (short)2); |
| | |
| | | _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"ç§»åºä»»å¡èµ·ç¹é误ï¼èµ·ç¹ï¼ã{task.CurrentAddress}ã"); |
| | | return null; |
| | | } |
| | | string[] targetCodes = task.TargetAddress.Split("-"); |
| | | if (targetCodes.Length == 3) |
| | | { |
| | | stackerCraneTaskCommand.EndRow = (byte)Convert.ToSByte(Convert.ToInt16(targetCodes[0]) % 2 != 0 ? (short)1 : (short)2); |
| | | stackerCraneTaskCommand.EndColumn = (byte)Convert.ToSByte(targetCodes[1]); |
| | | stackerCraneTaskCommand.EndLayer = (byte)Convert.ToSByte(targetCodes[2]); |
| | | } |
| | | else |
| | | { |
| | | //æ°æ®é
ç½®é误 |
| | | _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"ç§»åºä»»å¡ç»ç¹é误ï¼èµ·ç¹ï¼ã{task.NextAddress}ã"); |
| | | return null; |
| | | } |
| | | } |
| | | return stackerCraneTaskCommand; |
| | | } |