| | |
| | | { |
| | | try |
| | | { |
| | | var newTasks = _taskService.Db.Queryable<Dt_Task>().Where(x => (x.TaskState == TaskStatusEnum.AGV_Execute.ObjToInt()|| x.TaskState == TaskStatusEnum.New.ObjToInt()) && x.DeviceCode=="AGV" && x.TaskType!=999).ToList().OrderBy(x => x.Grade).ThenBy(x => x.CreateDate).ToList(); |
| | | var newTasks = _taskService.Db.Queryable<Dt_Task>().Where(x => (x.TaskState == TaskStatusEnum.AGV_Execute.ObjToInt()|| x.TaskState == TaskStatusEnum.New.ObjToInt()) && x.DeviceCode=="AGV").ToList().OrderBy(x => x.Grade).ThenBy(x => x.CreateDate).ToList(); |
| | | |
| | | if (newTasks.Count>0) |
| | | { |
| | |
| | | Code= "GoodPoint", |
| | | Value=stationMangerStart.AGVStationCode |
| | | }; |
| | | //夿æ¯å¦æåç½®ç¹ |
| | | if (!string.IsNullOrEmpty(stationMangerStart.AGVFrontCode)) |
| | | { |
| | | PointDetail pointDetail2 = new PointDetail() |
| | |
| | | Code = "PointB", |
| | | Value = stationMangerEnd.AGVStationCode |
| | | }; |
| | | if (!string.IsNullOrEmpty(stationMangerStart.AGVFrontCode)) |
| | | //夿æ¯å¦æåç½®ç¹ |
| | | if (!string.IsNullOrEmpty(stationMangerEnd.AGVFrontCode)) |
| | | { |
| | | PointDetail pointDetail4 = new PointDetail() |
| | | { |
| | |
| | | { |
| | | throw new Exception("æªæ¾å°AGVç«ç¹"); |
| | | } |
| | | //忾任塿¨¡ç |
| | | if (stationMangerStart.StationCode.Contains("PNT") && !stationMangerEnd.StationCode.Contains("PNT"))//è¯·æ±æ¾ |
| | | { |
| | | agvTaskSend.TaskCode = "DUIGAO1"; |
| | | if (stationMangerStart.StationType == 998 || stationMangerEnd.StationType == 998)//æ½ä¼é¡¶å车 |
| | | { |
| | | agvTaskSend.TaskCode = "DUOLUN1"; |
| | | } |
| | | } |
| | | else if (!stationMangerStart.StationCode.Contains("PNT") && stationMangerEnd.StationCode.Contains("PNT"))//请æ±å |
| | | { |
| | | agvTaskSend.TaskCode = "DUIGAO2"; |
| | | if (stationMangerStart.StationType==998 || stationMangerEnd.StationType == 998)//æ½ä¼é¡¶å车 |
| | | { |
| | | agvTaskSend.TaskCode = "DUOLUN2"; |
| | | } |
| | | } |
| | | else if (!stationMangerStart.StationCode.Contains("PNT") && !stationMangerEnd.StationCode.Contains("PNT"))//请æ±åæ¾ |
| | | { |
| | | agvTaskSend.TaskCode = "DUIGAO3"; |
| | | if (stationMangerStart.StationType == 998 || stationMangerEnd.StationType == 998)//æ½ä¼é¡¶å车 |
| | | { |
| | | agvTaskSend.TaskCode = "DUOLUN3"; |
| | | } |
| | | } |
| | | else if (stationMangerStart.StationCode.Contains("PNT") && stationMangerEnd.StationCode.Contains("PNT"))//æ è¯·æ± |
| | | { |
| | | agvTaskSend.TaskCode = "DUIGAO4"; |
| | | if (stationMangerStart.StationType == 998 || stationMangerEnd.StationType == 998)//æ½ä¼é¡¶å车 |
| | | { |
| | | agvTaskSend.TaskCode = "DUOLUN4"; |
| | | } |
| | | } |
| | | if (stationMangerStart.StationType == 998 || stationMangerEnd.StationType == 998)//æ½ä¼é¡¶å车 |
| | | { |
| | | agvTaskSend.Variables.FirstOrDefault(x => x.Code == "FHMH").Value = "0"; |
| | | agvTaskSend.Variables.FirstOrDefault(x => x.Code == "GoodPoint").Value = ""; |
| | | //ä¸åä»»å¡AGVä»»å¡é群 |
| | | agvTaskSend.AgvGroupCode = "QianF"; |
| | | PointDetail pointDetail2 = new PointDetail() |
| | | { |
| | | Code = "CostPoint", |
| | | Value = stationMangerStart.AGVStationCode |
| | | }; |
| | | agvTaskSend.Variables.Add(pointDetail2); |
| | | } |
| | | //å»¶æ¶ |
| | | Thread.Sleep(500); |
| | | //åéAGVä»»å¡ |
| | | WebResponseContent content = _taskService.AgvSendTask(agvTaskSend, APIEnum.AgvSendTask); |
| | | if (!content.Status) |
| | | throw new Exception(content.Message); |
| | | task.Dispatchertime = DateTime.Now; |
| | | _taskService.UpdateTask(task, TaskStatusEnum.AGV_Executing); |
| | | Thread.Sleep(500); |
| | | Thread.Sleep(200); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | |
| | | task.ExceptionMessage = ex.Message; |
| | | } |
| | | } |
| | | //æ´æ°ä»»å¡ |
| | | if (newTasks.Count > 0) |
| | | { |
| | | _taskService.UpdateData(newTasks); |