| | |
| | | agv_fromaddress = "", |
| | | agv_id = Guid.NewGuid(), |
| | | agv_tasknum = IdenxManager.GetTaskNo("KH-", "WMS"), |
| | | agv_grade = 2, |
| | | agv_grade = station.stationCode.Contains("W0100100") ? 3 : 2, |
| | | agv_createtime = DateTime.Now, |
| | | agv_taskstate = "Queue", |
| | | agv_qty = 1, |
| | |
| | | VOLContext context = new VOLContext(); |
| | | Idt_stationinfoRepository stationinfoRepository = new dt_stationinfoRepository(context); |
| | | Idt_agvtaskRepository agvtaskRepository = new dt_agvtaskRepository(context); |
| | | var stations = stationinfoRepository.Find(x => x.area == "2" && x.enable && x.location_state == LocationStateEnum.Empty.ToString()).OrderBy(x => x.line).OrderBy(x => x.column).ToList(); |
| | | if (stations.Count < 1) |
| | | { |
| | | stations = stationinfoRepository.Find(x => x.area == "3" && x.enable && x.location_state == LocationStateEnum.Empty.ToString()).OrderBy(x => x.line).OrderBy(x => x.column).ToList(); |
| | | } |
| | | var stations = stationinfoRepository.Find(x => x.stationCode.Contains("C01004") && x.enable && x.location_state == LocationStateEnum.Stroge.ToString()).OrderByDescending(x => x.column).ToList(); |
| | | //if (stations.Count < 1) |
| | | //{ |
| | | // stations = stationinfoRepository.Find(x => x.area == "3" && x.enable && x.location_state == LocationStateEnum.Empty.ToString()).OrderBy(x => x.line).OrderBy(x => x.column).ToList(); |
| | | //} |
| | | foreach (var station in stations) |
| | | { |
| | | if (agvtaskRepository.Find(x => x.agv_toaddress == station.stationCode).Any()) |
| | | if (agvtaskRepository.Find(x => x.agv_fromaddress == station.stationCode).Any()) |
| | | continue; |
| | | dt_agvtask taskPart = new dt_agvtask() |
| | | { |
| | | agv_fromaddress = "", |
| | | agv_fromaddress = station.stationCode, |
| | | agv_id = Guid.NewGuid(), |
| | | agv_tasknum = IdenxManager.GetTaskNo("KH-", "WMS"), |
| | | agv_grade = 2, |
| | | agv_grade = 1, |
| | | agv_createtime = DateTime.Now, |
| | | agv_taskstate = "Queue", |
| | | //agv_materielid = station.stationType, |
| | | agv_qty = 1, |
| | | StarQuantity = 0, |
| | | EndQuantity = 0,// EmptyStation.quantity, |
| | | agv_tasktype = "TaskType_EmptyPallet", |
| | | agv_toaddress = station.stationCode, |
| | | agv_toaddress = "",// EmptyStation.stationCode, |
| | | agv_userid = "ç³»ç»", |
| | | agv_TrayStatus = "EmptyTray",// station.tray_status, "SmallTray" : "LargeTray" |
| | | agv_Traytype = station.area == "4" ? "LargeTray" : "SmallTray", |
| | | agv_TrayStatus = "EmptyTray",//station.tray_status, |
| | | agv_Traytype = station.tray_type, |
| | | }; |
| | | agvtaskRepository.Add(taskPart, true); |
| | | station.location_state = LocationStateEnum.InBusy.ToString(); |
| | | station.location_state = LocationStateEnum.OutBusy.ToString(); |
| | | stationinfoRepository.Update(station, true); |
| | | WriteDBLog.Success("å建补åºå
空æä»»å¡", $"ä»»å¡ç¼å·ï¼{taskPart.agv_tasknum}", "PCS"); |
| | | //WriteDBLog.Success("å建空æä»»å¡", $"ä»»å¡ç¼å·ï¼{taskPart.agv_tasknum}", "PCS"); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | WriteDBLog.Error("å建补åºå
空æä»»å¡", $"é误信æ¯ï¼{ex.Message}", "PCS"); |
| | | //WriteDBLog.Error("å建补åºå
空æä»»å¡", $"é误信æ¯ï¼{ex.Message}", "PCS"); |
| | | //throw; |
| | | } |
| | | } |
| | | public static void task() |
| | | { |
| | | VOLContext context = new VOLContext(); |
| | | Idt_stationinfoRepository stationinfoRepository = new dt_stationinfoRepository(context); |
| | | Idt_agvtaskRepository agvtaskRepository = new dt_agvtaskRepository(context); |
| | | var tasks = agvtaskRepository.Find(x => x.agv_taskstate == "Queue").OrderBy(x => x.agv_createtime).ToList(); |
| | | foreach (var task in tasks) |
| | | { |
| | | if (task.agv_tasktype == "TaskType_EmptyPallet") |
| | | { |
| | | if (task.agv_toaddress == "") |
| | | { |
| | | var EmptyStation = stationinfoRepository.Find(x => x.area == "11" && x.stationCode.Contains("A") && x.quantity < 5 && x.enable).OrderByDescending(x => x.line).OrderBy(x => x.column).FirstOrDefault(); |
| | | if (EmptyStation == null) return; |
| | | if (EmptyStation.location_state == LocationStateEnum.Busy.ToString()) return; |
| | | task.agv_toaddress = EmptyStation.stationCode; |
| | | task.EndQuantity = EmptyStation.quantity; |
| | | task.agv_taskstate = "Create"; |
| | | EmptyStation.location_state = LocationStateEnum.Busy.ToString(); |
| | | stationinfoRepository.Update(EmptyStation, true); |
| | | agvtaskRepository.Update(task, true); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |