| | |
| | | { |
| | | VOLContext Context = new VOLContext(); |
| | | Idt_stationinfoRepository stationinfoRepository = new dt_stationinfoRepository(Context); |
| | | Idt_agvtaskRepository agvtaskRepository = new dt_agvtaskRepository(Context); |
| | | var EmptyStations = stationinfoRepository.Find(x => x.stationCode.Contains("DD") && x.quantity == 5 && x.enable).ToList(); |
| | | var EmptyStations = stationinfoRepository.Find(x => x.stationCode.Contains("DD") && x.location_state == LocationStateEnum.Stroge.ToString() && x.quantity == 5 && x.enable).ToList(); |
| | | foreach (var EmptyStation in EmptyStations) |
| | | { |
| | | try |
| | | { |
| | | if (agvtaskRepository.Find(x => x.agv_fromaddress == EmptyStation.stationCode || x.agv_toaddress == EmptyStation.stationCode).Any()) continue; |
| | | var area = EmptyStation.tray_type == "SmallTray" ? "11" : "10"; |
| | | var toEmptyStation = GetStation.EmptyPalletStation(area); |
| | | if (toEmptyStation != null) |
| | | { |
| | | #region åä¸ä¸ªç©ºæä½åªè½åæ¶çæä¸ä¸ªç©ºæä»»å¡ |
| | | if (agvtaskRepository.Find(x => x.agv_fromaddress == toEmptyStation.stationCode || x.agv_toaddress == toEmptyStation.stationCode).Any()) continue; |
| | | #endregion |
| | | |
| | | dt_agvtask agvtask = new dt_agvtask() |
| | | { |
| | | agv_fromaddress = EmptyStation.stationCode, |
| | | agv_id = Guid.NewGuid(), |
| | | agv_tasknum = IdenxManager.GetTaskNo("KH-", "WMS"), |
| | | agv_grade = 3, |
| | | agv_createtime = DateTime.Now, |
| | | agv_taskstate = "Create", |
| | | //agv_materielid = station.stationType, |
| | | agv_qty = EmptyStation.quantity - toEmptyStation.quantity, |
| | | StarQuantity = toEmptyStation.quantity, |
| | | EndQuantity = toEmptyStation.quantity, |
| | | agv_tasktype = "TaskType_EmptyPallet", |
| | | agv_toaddress = toEmptyStation.stationCode, |
| | | agv_userid = "ç³»ç»", |
| | | agv_TrayStatus = "EmptyTray",//station.tray_status, |
| | | agv_Traytype = EmptyStation.tray_type, |
| | | }; |
| | | agvtaskRepository.Add(agvtask, true); |
| | | EmptyStation.location_state = LocationStateEnum.Busy.ToString(); |
| | | stationinfoRepository.Update(EmptyStation, true); |
| | | toEmptyStation.location_state = LocationStateEnum.Busy.ToString(); |
| | | stationinfoRepository.Update(toEmptyStation, true); |
| | | WriteDBLog.Success("å建å çä½ç©ºæå
¥åºä»»å¡", $"ä»»å¡ç¼å·ï¼{agvtask.agv_tasknum}", "PCS"); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | WriteDBLog.Success("å建å çä½ç©ºæå
¥åºä»»å¡", $"é误信æ¯ï¼{ex.Message}", "PCS"); |
| | | } |
| | | |
| | | CreateEmptyTrayIn(stationinfoRepository, EmptyStation); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | |
| | | WriteDBLog.Success("å建å çä½ç©ºæå
¥åºä»»å¡", $"é误信æ¯ï¼{ex.Message}", "PCS"); |
| | | } |
| | | } |
| | | public static void CreateEmptyTrayIn(Idt_stationinfoRepository stationinfoRepository, dt_stationinfo EmptyStation) |
| | | { |
| | | VOLContext Context = new VOLContext(); |
| | | Idt_agvtaskRepository agvtaskRepository = new dt_agvtaskRepository(Context); |
| | | try |
| | | { |
| | | if (agvtaskRepository.Find(x => x.agv_fromaddress == EmptyStation.stationCode || x.agv_toaddress == EmptyStation.stationCode).Any()) return; |
| | | var area = EmptyStation.tray_type == "SmallTray" ? "11" : "10"; |
| | | var toEmptyStation = GetStation.EmptyPalletStation(area); |
| | | if (toEmptyStation != null) |
| | | { |
| | | #region åä¸ä¸ªç©ºæä½åªè½åæ¶çæä¸ä¸ªç©ºæä»»å¡ |
| | | if (agvtaskRepository.Find(x => x.agv_fromaddress == toEmptyStation.stationCode || x.agv_toaddress == toEmptyStation.stationCode).Any()) return; |
| | | #endregion |
| | | |
| | | dt_agvtask agvtask = new dt_agvtask() |
| | | { |
| | | agv_fromaddress = EmptyStation.stationCode, |
| | | agv_id = Guid.NewGuid(), |
| | | agv_tasknum = IdenxManager.GetTaskNo("KH-", "WMS"), |
| | | agv_grade = 3, |
| | | agv_createtime = DateTime.Now, |
| | | agv_taskstate = "Create", |
| | | //agv_materielid = station.stationType, |
| | | agv_qty = EmptyStation.quantity - toEmptyStation.quantity, |
| | | StarQuantity = toEmptyStation.quantity, |
| | | EndQuantity = toEmptyStation.quantity, |
| | | agv_tasktype = "TaskType_EmptyPallet", |
| | | agv_toaddress = toEmptyStation.stationCode, |
| | | agv_userid = "ç³»ç»", |
| | | agv_TrayStatus = "EmptyTray",//station.tray_status, |
| | | agv_Traytype = EmptyStation.tray_type, |
| | | }; |
| | | agvtaskRepository.Add(agvtask, true); |
| | | EmptyStation.location_state = LocationStateEnum.Busy.ToString(); |
| | | stationinfoRepository.Update(EmptyStation, true); |
| | | toEmptyStation.location_state = LocationStateEnum.Busy.ToString(); |
| | | stationinfoRepository.Update(toEmptyStation, true); |
| | | WriteDBLog.Success("å建å çä½ç©ºæå
¥åºä»»å¡", $"ä»»å¡ç¼å·ï¼{agvtask.agv_tasknum}", "PCS"); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | WriteDBLog.Error("å建å çä½ç©ºæå
¥åºä»»å¡", $"é误信æ¯ï¼{ex.Message}", "PCS"); |
| | | } |
| | | } |
| | | } |
| | | } |