|  |  |  | 
|---|
|  |  |  | using System.Linq; | 
|---|
|  |  |  | using System.Text; | 
|---|
|  |  |  | using System.Threading.Tasks; | 
|---|
|  |  |  | using WIDESEAWCS_Common; | 
|---|
|  |  |  | using WIDESEAWCS_Common.TaskEnum; | 
|---|
|  |  |  | using WIDESEAWCS_Core.Helper; | 
|---|
|  |  |  | using WIDESEAWCS_IBasicInfoRepository; | 
|---|
|  |  |  | 
|---|
|  |  |  | List<Dt_StationManger> stationMangers = _stationMangerRepository.QueryData(x => x.StationDeviceCode == hoister.DeviceCode); | 
|---|
|  |  |  | if (stationMangers == null || stationMangers.Count == 0) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | WriteInfo(hoister.DeviceName, "æªæ¾å°å¯¹åºç«å°ä¿¡æ¯"); | 
|---|
|  |  |  | WriteError(hoister.DeviceName, "æªæ¾å°å¯¹åºç«å°ä¿¡æ¯"); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return Task.CompletedTask; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (leisure && tray && !requestIn && !inbounding && !requestOut && !outbounding) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | Dt_Task task = _taskRepository.QueryFirst(x => x.TaskState == TaskInStatusEnum.InNew.ObjToInt() && string.IsNullOrEmpty(x.TargetAddress) && x.SourceAddress == deviceChildCode); | 
|---|
|  |  |  | Dt_Task task = _taskRepository.QueryFirst(x => x.TaskState == TaskStatusEnum.New.ObjToInt() && string.IsNullOrEmpty(x.TargetAddress) && x.SourceAddress == deviceChildCode && _taskService.TaskInboundTypes.Contains(x.TaskType)); | 
|---|
|  |  |  | if (task != null) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | bool isWrite = hoister.SetValue(HoisterDBName.RequestIn, true, deviceChildCode); | 
|---|
|  |  |  | WriteInfo(hoister.DeviceName, $"请æ±å
¥åº,设å¤ç¼å·:{deviceChildCode},ä»»å¡å·:{task.TaskNum}"); | 
|---|
|  |  |  | WriteError(hoister.DeviceName, $"请æ±å
¥åº,设å¤ç¼å·:{deviceChildCode},ä»»å¡å·:{task.TaskNum}"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else if (!leisure && tray && requestIn && inbounding && !requestOut && !outbounding) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | Dt_Task task = _taskRepository.QueryFirst(x => x.TaskState == TaskInStatusEnum.InNew.ObjToInt() && string.IsNullOrEmpty(x.TargetAddress) && x.SourceAddress == deviceChildCode); | 
|---|
|  |  |  | Dt_Task task = _taskRepository.QueryFirst(x => x.TaskState == TaskStatusEnum.New.ObjToInt() && string.IsNullOrEmpty(x.TargetAddress) && x.SourceAddress == deviceChildCode && _taskService.TaskInboundTypes.Contains(x.TaskType)); | 
|---|
|  |  |  | if (task != null) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | Dt_StationManger? stationManger = stationMangers.FirstOrDefault(x => x.StationDeviceCode == deviceChildCode); | 
|---|
|  |  |  | Dt_StationManger? stationManger = stationMangers.FirstOrDefault(x => x.StationCode == deviceChildCode); | 
|---|
|  |  |  | if (stationManger == null) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | WriteInfo(hoister.DeviceName, $"æªæ¾å°å¯¹åºç«å°ä¿¡æ¯,设å¤ç¼å·:{deviceChildCode},ä»»å¡å·:{task.TaskNum}"); | 
|---|
|  |  |  | WriteError(hoister.DeviceName, $"æªæ¾å°å¯¹åºç«å°ä¿¡æ¯,设å¤ç¼å·:{deviceChildCode},ä»»å¡å·:{task.TaskNum}"); | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | string? locationCode = _taskService.RequestAssignLocation(task.TaskNum, stationManger.StackerCraneCode); | 
|---|
|  |  |  | if (string.IsNullOrEmpty(locationCode)) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | WriteInfo(hoister.DeviceName, $"请æ±åé
è´§ä½è¿åä¿¡æ¯é误,设å¤ç¼å·:{deviceChildCode},ä»»å¡å·:{task.TaskNum}"); | 
|---|
|  |  |  | WriteError(hoister.DeviceName, $"请æ±åé
è´§ä½è¿åä¿¡æ¯é误,设å¤ç¼å·:{deviceChildCode},ä»»å¡å·:{task.TaskNum}"); | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | task.CurrentAddress = stationManger.StackerCraneStationCode; | 
|---|
|  |  |  | task.TargetAddress = locationCode; | 
|---|
|  |  |  | task.NextAddress = locationCode; | 
|---|
|  |  |  | task.Roadway = stationManger.StackerCraneCode; | 
|---|
|  |  |  | task.TaskState = TaskInStatusEnum.SC_InExecute.ObjToInt(); | 
|---|
|  |  |  | _taskRepository.UpdateData(task); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | task.DeviceCode = stationManger.StackerCraneCode; | 
|---|
|  |  |  | task.TaskState = TaskStatusEnum.SC_Execute.ObjToInt(); | 
|---|
|  |  |  | bool isWrite = hoister.SetValue(HoisterDBName.RequestIn, false, deviceChildCode); | 
|---|
|  |  |  | if (isWrite) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | _taskService.UpdateTask(task, TaskStatusEnum.SC_Execute, deviceCode: task.DeviceCode, targetAddress: task.TargetAddress, currentAddress: task.CurrentAddress, nextAddress: task.NextAddress); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else | 
|---|
|  |  |  | { | 
|---|
|  |  |  | WriteInfo(hoister.DeviceName, $"æªæ¾å°å¯¹åºç«å°ä¿¡æ¯,{deviceChildCode}"); | 
|---|
|  |  |  | WriteError(hoister.DeviceName, $"æªæ¾å°å¯¹åºä»»å¡ä¿¡æ¯,{deviceChildCode}"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else if (leisure && !tray && !requestIn && !inbounding && !requestOut && !outbounding) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | Dt_Task task = _taskRepository.QueryFirst(x => x.TaskState == TaskOutStatusEnum.OutNew.ObjToInt() && string.IsNullOrEmpty(x.TargetAddress)); | 
|---|
|  |  |  | Dt_StationManger? stationManger = stationMangers.FirstOrDefault(x => x.StationCode == deviceChildCode); | 
|---|
|  |  |  | if (stationManger == null) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | WriteError(hoister.DeviceName, $"æªæ¾å°å¯¹åºç«å°ä¿¡æ¯,设å¤ç¼å·:{deviceChildCode}"); | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (stationManger.StationType != StationTypeEnum.StationType_InboundAndOutbound.ObjToInt()) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | Dt_Task task = _taskRepository.QueryFirst(x => x.TaskState == TaskStatusEnum.New.ObjToInt() && string.IsNullOrEmpty(x.TargetAddress) && _taskService.TaskOutboundTypes.Contains(x.TaskType) && x.TaskType != TaskTypeEnum.MesOutbound.ObjToInt() && x.Roadway== stationManger.StackerCraneCode); | 
|---|
|  |  |  | if (task != null) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | task.TaskState=TaskStatusEnum.HT_Executing.ObjToInt(); | 
|---|
|  |  |  | bool isWrite = hoister.SetValue(HoisterDBName.RequestOut, true, deviceChildCode); | 
|---|
|  |  |  | WriteInfo(hoister.DeviceName, $"请æ±åºåº,设å¤ç¼å·:{deviceChildCode},ä»»å¡å·:{task.TaskNum}"); | 
|---|
|  |  |  | if (isWrite) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | _taskService.UpdateTask(task, TaskStatusEnum.HT_Executing); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | WriteError(hoister.DeviceName, $"请æ±åºåº,设å¤ç¼å·:{deviceChildCode},ä»»å¡å·:{task.TaskNum}"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else if (!leisure && !tray && !requestIn && !inbounding && requestOut && outbounding) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | Dt_Task task = _taskRepository.QueryFirst(x => x.TaskState == TaskInStatusEnum.InNew.ObjToInt() && string.IsNullOrEmpty(x.TargetAddress) && x.SourceAddress == deviceChildCode); | 
|---|
|  |  |  | Dt_Task task = _taskRepository.QueryFirst(x => x.TaskState == TaskStatusEnum.HT_Executing.ObjToInt() && string.IsNullOrEmpty(x.TargetAddress) && _taskService.TaskOutboundTypes.Contains(x.TaskType)); | 
|---|
|  |  |  | if (task != null) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | Dt_StationManger? stationManger = stationMangers.FirstOrDefault(x => x.StationDeviceCode == deviceChildCode); | 
|---|
|  |  |  | Dt_StationManger? stationManger = stationMangers.FirstOrDefault(x => x.StationCode == deviceChildCode); | 
|---|
|  |  |  | if (stationManger == null) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | WriteInfo(hoister.DeviceName, $"æªæ¾å°å¯¹åºç«å°ä¿¡æ¯,设å¤ç¼å·:{deviceChildCode},ä»»å¡å·:{task.TaskNum}"); | 
|---|
|  |  |  | WriteError(hoister.DeviceName, $"æªæ¾å°å¯¹åºç«å°ä¿¡æ¯,设å¤ç¼å·:{deviceChildCode},ä»»å¡å·:{task.TaskNum}"); | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | task.TargetAddress = deviceChildCode; | 
|---|
|  |  |  | task.NextAddress = deviceChildCode; | 
|---|
|  |  |  | task.Roadway = stationManger.StackerCraneCode; | 
|---|
|  |  |  | task.TaskState = TaskInStatusEnum.SC_InExecute.ObjToInt(); | 
|---|
|  |  |  | _taskRepository.UpdateData(task); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | bool isWrite = hoister.SetValue(HoisterDBName.RequestIn, false, deviceChildCode); | 
|---|
|  |  |  | task.NextAddress = stationManger.StackerCraneStationCode; ; | 
|---|
|  |  |  | task.DeviceCode = stationManger.StackerCraneCode; | 
|---|
|  |  |  | task.TaskState = TaskStatusEnum.SC_Execute.ObjToInt(); | 
|---|
|  |  |  | bool isWrite = hoister.SetValue(HoisterDBName.RequestOut, false, deviceChildCode); | 
|---|
|  |  |  | if (isWrite) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | _taskService.UpdateTask(task, TaskStatusEnum.SC_Execute, deviceCode: task.DeviceCode, targetAddress: task.TargetAddress, nextAddress: task.NextAddress); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else | 
|---|
|  |  |  | { | 
|---|
|  |  |  | WriteInfo(hoister.DeviceName, $"æªæ¾å°å¯¹åºç«å°ä¿¡æ¯,{deviceChildCode}"); | 
|---|
|  |  |  | WriteError(hoister.DeviceName, $"æªæ¾å°å¯¹åºç«å°ä¿¡æ¯,{deviceChildCode}"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //if (tray && leisure) | 
|---|
|  |  |  | //{ | 
|---|
|  |  |  | //#region æ¥è¯¢ç»çä¿¡æ¯ | 
|---|
|  |  |  | //åWMSç³è¯·æ¥è¯¢å½åæåæºå£çç»çä¿¡æ¯ï¼åå¨ç»çä¿¡æ¯è¿åå
¥åºä»»å¡å¹¶ååºå
¥åºç³è¯· | 
|---|
|  |  |  | //var task = _taskService.QueryExecutingConveyorLineTask(1, deviceChildCode); | 
|---|
|  |  |  | //if (Leisure && task != null) | 
|---|
|  |  |  | //    Hoister.SetValue(HoisterDBName.RequestIn, true, deviceChildCode); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //#endregion | 
|---|
|  |  |  | //var Inbounding = Hoister.GetValue<HoisterDBName, bool>(HoisterDBName.Inbounding, deviceChildCode); | 
|---|
|  |  |  | //if (Inbounding && task != null) | 
|---|
|  |  |  | //{ | 
|---|
|  |  |  | //    task.TaskState = (int)TaskInStatusEnum.SC_InExecute; | 
|---|
|  |  |  | //    task.NextAddress = "001-003-001"; | 
|---|
|  |  |  | //    _taskService.UpdateData(task); | 
|---|
|  |  |  | //    //æ´æ°ä»»å¡ç¶æå¹¶åæ¶å
¥åºç³è¯· | 
|---|
|  |  |  | //    Hoister.SetValue(HoisterDBName.RequestIn, false, deviceChildCode); | 
|---|
|  |  |  | //} | 
|---|
|  |  |  | //} | 
|---|
|  |  |  | //else | 
|---|
|  |  |  | //{ | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //æ¥è¯¢åºåºä»»å¡,åå¨åºåºä»»å¡ååºåºåºç³è¯· | 
|---|
|  |  |  | //var task = _taskService.QueryExecutingConveyorLineTask(2, deviceChildCode); | 
|---|
|  |  |  | //if (task != null && Leisure) | 
|---|
|  |  |  | //    Hoister.SetValue(HoisterDBName.RequestOut, true, deviceChildCode); | 
|---|
|  |  |  | //var Outbounding = Hoister.GetValue<HoisterDBName, bool>(HoisterDBName.Outbounding, deviceChildCode); | 
|---|
|  |  |  | //if (Outbounding && task != null) | 
|---|
|  |  |  | //{ | 
|---|
|  |  |  | //    task.NextAddress = deviceChildCode; | 
|---|
|  |  |  | //    task.TargetAddress = deviceChildCode; | 
|---|
|  |  |  | //    task.TaskState = (int)TaskOutStatusEnum.OutNew; | 
|---|
|  |  |  | //    _taskService.UpdateData(task); | 
|---|
|  |  |  | //    //æ´æ°ä»»å¡ç¶æå¹¶åæ¶åºåºç³è¯· | 
|---|
|  |  |  | //    Hoister.SetValue(HoisterDBName.RequestOut, false, deviceChildCode); | 
|---|
|  |  |  | //} | 
|---|
|  |  |  | //} | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|