| | |
| | | if (flag && value != null) |
| | | { |
| | | OtherDevice device = (OtherDevice)value; |
| | | List<string> deviceStations = device.DeviceProDTOs.Select(x => x.DeviceChildCode).ToList(); |
| | | List<string> deviceStations = device.DeviceProDTOs.Select(x => x.DeviceChildCode).Distinct().ToList(); |
| | | List<Dt_StationManger> stationMangers = _stationMangerRepository.QueryData(x => x.StationDeviceCode == device.DeviceCode); |
| | | foreach (var item in stationMangers.Where(x => deviceStations.Contains(x.StationCode))) |
| | | { |
| | | DeviceProDTO? deviceProRead = device.DeviceProDTOs.Where(x => x.DeviceChildCode == item.StationCode && x.DeviceProParamType == nameof(R_ConveyorLineCPDB)).OrderBy(x => x.DeviceProOffset).FirstOrDefault(); |
| | | DeviceProDTO? deviceProWrite = device.DeviceProDTOs.Where(x => x.DeviceChildCode == item.StationCode && x.DeviceProParamType == nameof(W_ConveyorLineCPDB)).OrderBy(x => x.DeviceProOffset).FirstOrDefault(); |
| | | if (item.StationType == StationTypeEnum.StationType_InStartAndOutEnd.ObjToInt() && deviceProRead != null && deviceProWrite != null) |
| | | { |
| | | R_ConveyorLineCPInfo conveyorLineInfoRead = device.Communicator.ReadCustomer<R_ConveyorLineCPInfo>(deviceProRead.DeviceProAddress); |
| | | if (conveyorLineInfoRead!=null && conveyorLineInfoRead.Command == 4 && conveyorLineInfoRead.TaskNo <= 0) |
| | | { |
| | | Dt_Task task = _taskRepository.QueryFirst(x => x.CurrentAddress == item.StationCode && _taskService.TaskInboundTypes.Contains(x.TaskType) && x.TaskState == TaskStatusEnum.New.ObjToInt() && x.DeviceCode == device.DeviceCode); |
| | | if (task != null) |
| | | { |
| | | //åé
å··é åå
¥æçæ°æ® |
| | | List<Dt_Router> routers = _routerService.QueryNextRoutes(item.StationCode, task.Roadway, task.TaskType); |
| | | Dt_Router? router = routers.FirstOrDefault(); |
| | | if (routers == null || routers.Count == 0 || router == null) |
| | | { |
| | | WriteError(item.StationName, $"æªæ¾å°å¯¹åºè·¯ç±ä¿¡æ¯,设å¤ç¼å·:{item.StationCode},ä»»å¡å·:{task.TaskNum}"); |
| | | continue; |
| | | } |
| | | if (routers.Count > 1) |
| | | { |
| | | WriteError(item.StationName, $"è·¯ç±ä¿¡æ¯é
ç½®é误,设å¤ç¼å·:{item.StationCode},ä»»å¡å·:{task.TaskNum}"); |
| | | continue; |
| | | } |
| | | //åå
¥å
¥åºçº¿ä½å°å |
| | | device.SetValue(W_ConveyorLineCPDB.W_TargetAddress, router.NextPosi, item.StationCode); |
| | | device.SetValue(W_ConveyorLineCPDB.W_TaskNo, task.TaskNum, item.StationCode); |
| | | device.SetValue(W_ConveyorLineCPDB.W_Command, 1, item.StationCode); |
| | | //æ´æ°ä»»å¡ä¿¡æ¯ |
| | | task.CurrentAddress = item.StationCode; |
| | | task.NextAddress = router.NextPosi; |
| | | task.PalletType = 1; |
| | | task.PalletCode = conveyorLineInfoRead.PalletCode; |
| | | _taskService.UpdateTask(task, TaskStatusEnum.Line_Executing); |
| | | WriteError(item.StationName, $"ä»»å¡å·{conveyorLineInfoRead.TaskNo}ä¸ä¸æ¥"); |
| | | } |
| | | } |
| | | } |
| | | else if (item.StationType == StationTypeEnum.StationType_OnlyInbound.ObjToInt() && deviceProRead != null) |
| | | { |
| | | R_ConveyorLineCPInfo conveyorLineInfoRead = device.Communicator.ReadCustomer<R_ConveyorLineCPInfo>(deviceProRead.DeviceProAddress); |
| | | if (conveyorLineInfoRead != null && conveyorLineInfoRead.Command == 2 && conveyorLineInfoRead.TaskNo > 0) |
| | | { |
| | | Dt_Task task = _taskRepository.QueryFirst(x => x.TaskNum == conveyorLineInfoRead.TaskNo && x.NextAddress == item.StationCode && _taskService.TaskInboundTypes.Contains(x.TaskType) && x.TaskState == TaskStatusEnum.Line_Executing.ObjToInt() && x.DeviceCode == device.DeviceCode); |
| | | if (task != null) |
| | | { |
| | | //åé
è´§ä½ |
| | | string local = "SC03_CP-002-064-001-01"; |
| | | task.CurrentAddress = item.StackerCraneStationCode; |
| | | task.TargetAddress = local; |
| | | task.NextAddress = local; |
| | | task.DeviceCode = item.StackerCraneCode; |
| | | _taskService.UpdateTask(task, TaskStatusEnum.SC_Execute); |
| | | WriteError(item.StationName, $"ä»»å¡å·:{task.TaskNum}è¿è¡å åæºå
¥åº"); |
| | | //string? locationCode = _taskService.RequestAssignLocation(task.TaskNum, "AGV_CP"); |
| | | //if (string.IsNullOrEmpty(locationCode) && task.TaskType != TaskTypeEnum.EmptyProductBack.ObjToInt()) |
| | | //{ |
| | | // WriteError(item.StationName, $"请æ±åé
è´§ä½è¿åä¿¡æ¯é误,设å¤ç¼å·:{item.StationCode},ä»»å¡å·:{task.TaskNum}"); |
| | | // continue; |
| | | //} |
| | | |
| | | } |
| | | } |
| | | } |
| | | else if (item.StationType == StationTypeEnum.StationType_OnlyOutbound.ObjToInt() && deviceProRead != null && deviceProWrite != null) |
| | | { |
| | | R_ConveyorLineCPInfo conveyorLineInfoRead = device.Communicator.ReadCustomer<R_ConveyorLineCPInfo>(deviceProRead.DeviceProAddress); |
| | | if (conveyorLineInfoRead != null && conveyorLineInfoRead.Command == 4 && conveyorLineInfoRead.TaskNo <= 0) |
| | | { |
| | | //è·ååºåºç«å°æ¯å¦åå¨åºåºå¾
æ§è¡ä»»å¡ |
| | | Dt_Task task = _taskRepository.QueryFirst(x => x.CurrentAddress == item.StationCode && _taskService.TaskOutboundTypes.Contains(x.TaskType) |
| | | && x.TaskState == TaskStatusEnum.Line_Execute.ObjToInt() && x.DeviceCode == device.DeviceCode); |
| | | if (task != null) |
| | | { |
| | | //è·åè·¯ç±é
ç½® |
| | | List<Dt_Router> routers = _routerRepository.QueryData(x => x.InOutType == task.TaskType && task.CurrentAddress == x.StartPosi); |
| | | Dt_Router router = routers.FirstOrDefault(); |
| | | if (router == null) |
| | | { |
| | | WriteError(item.StationName, $"ä»»å¡å·:{task.TaskNum}æªæ¾å°è·¯ç±é
置信æ¯"); |
| | | return Task.CompletedTask; |
| | | } |
| | | //åå
¥åºåºçº¿ä½å°å |
| | | device.SetValue(W_ConveyorLineCPDB.W_TargetAddress, router.NextPosi, item.StationCode); |
| | | device.SetValue(W_ConveyorLineCPDB.W_TaskNo, task.TaskNum, item.StationCode); |
| | | device.SetValue(W_ConveyorLineCPDB.W_Command, 1, item.StationCode); |
| | | _taskService.UpdateTask(task, TaskStatusEnum.Line_Executing); |
| | | WriteError(item.StationName, $"ä»»å¡å·:{task.TaskNum}è¿è¡çº¿ä½åºåº"); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | WriteError(item.StationName, $"æªæ¾å°è®¾å¤åç¼å·{item.StationCode}çå议信æ¯"); |
| | | } |
| | | } |
| | | } |
| | | return Task.CompletedTask; |