| | |
| | | using WIDESEA_Comm.TaskNo; |
| | | using WIDESEA_WCS.JobsPart.Common; |
| | | using System.Xml.Linq; |
| | | using WIDESEA_Common; |
| | | using System.Net; |
| | | |
| | | namespace WIDESEA_WCS |
| | | { |
| | |
| | | { |
| | | |
| | | #region 夿åºåå·æ¯å¦ä¸è´ |
| | | var area = Gantry_client.ReadByOrder<Int16>("place_prog", number);//æ¾æå®æçåºåå· |
| | | //var area = Gantry_client.ReadByOrder<Int16>("place_prog", number);//æ¾æå®æçåºåå· |
| | | |
| | | WriteLog.Write_Log(number + "åæå®æåºé", bindSNS[bindSNS.Length - 1], "夿åºåå·æ¯å¦ä¸è´", $"PCSåºåå·ï¼{AreaNr}ï¼\næ¡æ¶åºåå·ï¼{area}\né误信æ¯ï¼PCSåºåå·ä¸æ¡æ¶åºåå·ä¸ä¸è´ï¼"); |
| | | //WriteLog.Write_Log(number + "åæå®æåºé", bindSNS[bindSNS.Length - 1], "夿åºåå·æ¯å¦ä¸è´", $"PCSåºåå·ï¼{AreaNr}ï¼\næ¡æ¶åºåå·ï¼{area}\né误信æ¯ï¼PCSåºåå·ä¸æ¡æ¶åºåå·ä¸ä¸è´ï¼"); |
| | | //if (AreaNr != area) |
| | | //{ |
| | | // client.WriteByOrder("W_AlarmSignal", (Int16)2, number);//æ¥è¦ |
| | |
| | | #endregion |
| | | |
| | | #region å¤æè½¦è½®æ°éæ¯å¦ä¸è´ |
| | | var quantity = Gantry_client.ReadByOrder<Int16>("pos_prog", number);//æ¡æ¶è®°å½ç车轮æ°é |
| | | //var quantity = Gantry_client.ReadByOrder<Int16>("pos_prog", number);//æ¡æ¶è®°å½ç车轮æ°é |
| | | |
| | | WriteLog.Write_Log(number + "åæå®æåºé", bindSNS[bindSNS.Length - 1], "å¤æè½¦è½®æ°éæ¯å¦ä¸è´", $"åºåå·ï¼{AreaNr}ï¼\næ¡æ¶è½¦è½®æ°ï¼{quantity}\nPCS车轮æ°ï¼{station.quantity}\né误信æ¯ï¼PCSåºåå·ä¸æ¡æ¶åºåå·ä¸ä¸è´ï¼"); |
| | | //WriteLog.Write_Log(number + "åæå®æåºé", bindSNS[bindSNS.Length - 1], "å¤æè½¦è½®æ°éæ¯å¦ä¸è´", $"åºåå·ï¼{AreaNr}ï¼\næ¡æ¶è½¦è½®æ°ï¼{quantity}\nPCS车轮æ°ï¼{station.quantity}\né误信æ¯ï¼PCSåºåå·ä¸æ¡æ¶åºåå·ä¸ä¸è´ï¼"); |
| | | //if (quantity != station.quantity) |
| | | //{ |
| | | // client.WriteByOrder("W_AlarmSignal", (Int16)2, number);//æ¥è¦ |
| | |
| | | { |
| | | Station.location_state = LocationStateEnum.Abnormal.ToString(); |
| | | Station.remark = "车轮æ°éä¸SNå·æ°éä¸ä¸è´"; |
| | | stationinfoRepository.Update(Station, true); |
| | | stationinfoRepository.Update(Station, x => new { x.location_state, x.remark }, true); |
| | | Gantry_client.WriteByOrder("W_RequestUnload", false, number);//ä¿¡å·ä¸ºfalseæ¡æ¶åæ¢è¿å
¥ |
| | | #region æ¥å¿è®°å½ |
| | | WriteDBLog.Error("䏿åº", $"åå
¥æ¡æ¶ä¿¡æ¯ï¼\nW_RequestUnloadï¼false\n\n{Station.stationCode}车轮æ°éä¸SNå·æ°éä¸ä¸è´", "PCS"); |
| | | //WriteDBLog.Error("䏿åº", $"åå
¥æ¡æ¶ä¿¡æ¯ï¼\nW_RequestUnloadï¼false\n\n{Station.stationCode}车轮æ°éä¸SNå·æ°éä¸ä¸è´", "PCS"); |
| | | #endregion |
| | | return; |
| | | } |
| | |
| | | |
| | | if (PalletSignal == 1 && MaterialSignal == 1) |
| | | { |
| | | Gantry_client.WriteByOrder("W_Wheel_Type", (Int16)Convert.ToInt16(QueryMateriel(Station.stationType) == null ? QueryMateriel1(Station.stationType).TypeId : QueryMateriel(Station.stationType).TypeId), number);//车轮类å |
| | | var geometry = QueryMateriel(Station.stationType); |
| | | if (geometry == null) |
| | | { |
| | | Station.remark = "æªæ¾å°è½¦è½®ä¿¡æ¯"; |
| | | stationinfoRepository.Update(Station, x => new { x.remark }, true); |
| | | Gantry_client.WriteByOrder("W_RequestUnload", false, number);//ä¿¡å·ä¸ºfalseæ¡æ¶åæ¢è¿å
¥ |
| | | return; |
| | | } |
| | | Gantry_client.WriteByOrder("W_Wheel_Type", (Int16)Convert.ToInt16(geometry.TypeId), number);//车轮类å |
| | | var area = Convert.ToInt16(Station.stationCode.Substring(Station.stationCode.Length - 1, 1)); |
| | | Gantry_client.WriteByOrder("W_AreaNr", (Int16)area, number);//åºåè´§ä½å· |
| | | Gantry_client.WriteByOrder("W_IndexNr", (Int16)SNS.Length, number);//æçä¸ç第å 个车轮 |
| | |
| | | Gantry_client.WriteByOrder("W_RequestUnload", true, number); |
| | | #region æ¥å¿è®°å½ |
| | | WriteDBLog.Success("䏿åºç³è¯·", $"读åæçå
çµä¿¡å·ï¼{PalletSignal}\n读å第ä¸ä¸ªè½¦è½®å
çµä¿¡å·ï¼{MaterialSignal}\n\n" + |
| | | $"åå
¥æ¡æ¶ä¿¡æ¯ï¼\nåºåè´§ä½å·ï¼{area}\næçä¸ç第å 个车轮ï¼{SNS.Length}\næçç±»åï¼{1}\n车轮类åï¼{(QueryMateriel(Station.stationType) == null ? QueryMateriel1(Station.stationType).TypeId : QueryMateriel(Station.stationType).TypeId)}" + |
| | | $"åå
¥æ¡æ¶ä¿¡æ¯ï¼\nåºåè´§ä½å·ï¼{area}\næçä¸ç第å 个车轮ï¼{SNS.Length}\næçç±»åï¼{1}\n车轮类åï¼{geometry.TypeId}" + |
| | | $"\n车轮SNå·ï¼{SNS[SNS.Length - 1]}\nW_RequestUnloadï¼true", "PCS"); |
| | | #endregion |
| | | } |
| | |
| | | } |
| | | |
| | | #region æ´æ°ä¸ä¸ªæ£æµä¸æä»»å¡ |
| | | Idt_agvtaskRepository agvtaskService = new dt_agvtaskRepository(Context); |
| | | if (!agvtaskService.Find(x => x.agv_toaddress == Station.stationCode).Any()) |
| | | { |
| | | var task = agvtaskService.Find(x => x.agv_taskstate == "Queue" && (x.agv_tasktype == "TaskType_OutsourceOutbound" || x.agv_tasktype == "TaskType_Outbound") && x.agv_toaddress == "").OrderByDescending(x => x.agv_grade).ThenBy(x => x.agv_createtime).FirstOrDefault(); |
| | | if (task != null) |
| | | { |
| | | task.agv_taskstate = "Create"; |
| | | task.agv_toaddress = Station.stationCode; |
| | | agvtaskService.Update(task, true); |
| | | WriteDBLog.Success("æ´æ°ä¸ä¸ªæ£æµä¸æä»»å¡", $"ä»»å¡ç¼å·ï¼{task.agv_tasknum}", "PCS"); |
| | | } |
| | | } |
| | | //Idt_agvtaskRepository agvtaskService = new dt_agvtaskRepository(Context); |
| | | //if (!agvtaskService.Find(x => x.agv_toaddress == Station.stationCode).Any()) |
| | | //{ |
| | | // var task = agvtaskService.Find(x => x.agv_taskstate == "Queue" && (x.agv_tasktype == "TaskType_OutsourceOutbound" || x.agv_tasktype == "TaskType_Outbound") && x.agv_toaddress == "").OrderByDescending(x => x.agv_grade).ThenBy(x => x.agv_createtime).FirstOrDefault(); |
| | | // if (task != null) |
| | | // { |
| | | // task.agv_taskstate = "Create"; |
| | | // task.agv_toaddress = Station.stationCode; |
| | | // agvtaskService.Update(task, true); |
| | | // WriteDBLog.Success("æ´æ°ä¸ä¸ªæ£æµä¸æä»»å¡", $"ä»»å¡ç¼å·ï¼{task.agv_tasknum}", "PCS"); |
| | | // } |
| | | //} |
| | | #endregion |
| | | } |
| | | else |
| | | { |
| | | var count = Gantry_client.ReadByOrder<Int16>("W_IndexNr", number); |
| | | if (Station.quantity != count) Gantry_client.WriteByOrder("W_RequestUnload", false, number); |
| | | } |
| | | } |
| | | else |
| | |
| | | var MaterialSignal = (Int16)DBExtension.Read(details.Where(x => x.plcdetail_name == "R_MaterialSignal").First(), client);//读åè´§ç©ä¿¡å·:1:æ,2æ |
| | | if (PalletSignal == 1 && MaterialSignal == 2 && (station.stationCode.Contains("S0100100") ? station.tray_status == "EmptyTray" : true)) |
| | | { |
| | | var area = station.tray_type == "SmallTray" ? "11" : "10"; |
| | | remark = "æ¥è¯¢æ¯å¦åå¨è¡¥ç©ºæéåä»»å¡"; |
| | | var task = agvtaskService.Find(x => (x.agv_toaddress.Contains("W") || x.agv_toaddress.Contains("X")) && x.agv_taskstate == "Queue" && x.agv_tasktype == "TaskType_EmptyPallet" && x.agv_Traytype == station.tray_type).OrderByDescending(x => x.agv_grade).ThenBy(x => x.agv_createtime).FirstOrDefault(); |
| | | if (task != null) |
| | | { |
| | | task.agv_fromaddress = station.stationCode; |
| | | task.StarQuantity = 0; |
| | | task.agv_taskstate = "Create"; |
| | | if (station.stationCode.Contains("S0100100")) |
| | | task.agv_grade = 3; |
| | | agvtaskService.Update(task, true); |
| | | station.location_state = LocationStateEnum.Busy.ToString(); |
| | | stationinfoRepository.Update(station, true); |
| | | WriteDBLog.Success("æ´æ°ç©ºæéåä»»å¡", $"ä»»å¡ç¼å·ï¼{task.agv_tasknum}ï¼æçä¿¡å·:{PalletSignal},è´§ç©ä¿¡å·:{MaterialSignal}", "PCS"); |
| | | continue; |
| | | } |
| | | remark = "æ¥è¯¢ç©ºæå çä½"; |
| | | #region 空æå ç |
| | | if (stationCode.Contains("S")) |
| | | { |
| | | var EmptyStations = stationinfoRepository.Find(x => x.stationCode.Contains("DD") && x.quantity < 5 && x.enable).ToList(); |
| | | EmptyStation = EmptyStations.Where(x => x.tray_type == station.tray_type && x.location_state == LocationStateEnum.Stroge.ToString()).FirstOrDefault(); |
| | | if (EmptyStation == null) |
| | | EmptyStation = EmptyStations.Where(x => x.location_state == LocationStateEnum.Empty.ToString() && x.quantity == 0 && x.enable).FirstOrDefault(); |
| | | if (EmptyStation == null) |
| | | { |
| | | EmptyStation = EmptyStations.Where(x => x.location_state == LocationStateEnum.Stroge.ToString() && x.quantity > 0 && x.enable).OrderByDescending(x => x.quantity).FirstOrDefault(); |
| | | if (EmptyStation != null) EmptyTray.CreateEmptyTrayIn(stationinfoRepository, EmptyStation); |
| | | } |
| | | } |
| | | #region æ¥è¯¢æ¯å¦åå¨è¡¥ç©ºæéåä»»å¡ |
| | | //var area = station.tray_type == "SmallTray" ? "11" : "10"; |
| | | //remark = "æ¥è¯¢æ¯å¦åå¨è¡¥ç©ºæéåä»»å¡"; |
| | | //var task = agvtaskService.Find(x => (x.agv_toaddress.Contains("W") || x.agv_toaddress.Contains("X")) && x.agv_taskstate == "Queue" && x.agv_tasktype == "TaskType_EmptyPallet" && x.agv_Traytype == station.tray_type).OrderByDescending(x => x.agv_grade).ThenBy(x => x.agv_createtime).FirstOrDefault(); |
| | | //if (task != null) |
| | | //{ |
| | | // task.agv_fromaddress = station.stationCode; |
| | | // task.StarQuantity = 0; |
| | | // task.agv_taskstate = "Create"; |
| | | // if (station.stationCode.Contains("S0100100")) |
| | | // task.agv_grade = 3; |
| | | // agvtaskService.Update(task, true); |
| | | // station.location_state = LocationStateEnum.Busy.ToString(); |
| | | // stationinfoRepository.Update(station, true); |
| | | // WriteDBLog.Success("æ´æ°è¡¥ç©ºæéåä»»å¡", $"ä»»å¡ç¼å·ï¼{task.agv_tasknum}ï¼æçä¿¡å·:{PalletSignal},è´§ç©ä¿¡å·:{MaterialSignal}", "PCS"); |
| | | // continue; |
| | | //} |
| | | #endregion |
| | | else |
| | | { |
| | | remark = "æ¥æ¾åºå
空æä½"; |
| | | EmptyStation = GetStation.EmptyPalletStation(area); |
| | | if (EmptyStation != null) |
| | | if (agvtaskService.Find(x => x.agv_fromaddress == EmptyStation.stationCode || x.agv_toaddress == EmptyStation.stationCode).Any()) return; |
| | | } |
| | | |
| | | |
| | | if (EmptyStation != null) |
| | | #region å建å空æéåä»»å¡ |
| | | dt_agvtask agvtask = new dt_agvtask() |
| | | { |
| | | #region åä¸ä¸ªç©ºæä½åªè½åæ¶çæä¸ä¸ªç©ºæä»»å¡ |
| | | //remark = "æ¥è¯¢ç©ºæä½æ¯å¦åå¨ä»»å¡"; |
| | | //if (agvtaskService.Find(x => x.agv_fromaddress == EmptyStation.stationCode || x.agv_toaddress == EmptyStation.stationCode).Any()) |
| | | // return; |
| | | #endregion |
| | | dt_agvtask agvtask = new dt_agvtask() |
| | | { |
| | | agv_fromaddress = station.stationCode, |
| | | agv_id = Guid.NewGuid(), |
| | | agv_tasknum = IdenxManager.GetTaskNo("KH-", "WMS"), |
| | | agv_grade = station.stationCode.Contains("S0100100") ? 3 : 1, |
| | | agv_createtime = DateTime.Now, |
| | | agv_taskstate = "Create", |
| | | //agv_materielid = station.stationType, |
| | | agv_qty = 1, |
| | | StarQuantity = 0, |
| | | EndQuantity = EmptyStation.quantity, |
| | | agv_tasktype = "TaskType_EmptyPallet", |
| | | agv_toaddress = EmptyStation.stationCode, |
| | | agv_userid = "ç³»ç»", |
| | | agv_TrayStatus = "EmptyTray",//station.tray_status, |
| | | agv_Traytype = station.tray_type, |
| | | }; |
| | | agvtaskService.Add(agvtask, true); |
| | | station.location_state = LocationStateEnum.Busy.ToString(); |
| | | stationinfoRepository.Update(station, true); |
| | | EmptyStation.location_state = LocationStateEnum.Busy.ToString(); |
| | | stationinfoRepository.Update(EmptyStation, true); |
| | | WriteDBLog.Success("å建èªå¨å空æä»»å¡", $"ä»»å¡ç¼å·ï¼{agvtask.agv_tasknum}ï¼æçä¿¡å·:{PalletSignal},è´§ç©ä¿¡å·:{MaterialSignal}", "PCS"); |
| | | } |
| | | agv_fromaddress = station.stationCode, |
| | | agv_id = Guid.NewGuid(), |
| | | agv_tasknum = IdenxManager.GetTaskNo("KH-", "WMS"), |
| | | agv_grade = station.stationCode.Contains("S0100100") ? 3 : 1, |
| | | agv_createtime = DateTime.Now, |
| | | agv_taskstate = AGVTaskStateEnum.Queue.ToString(), |
| | | agv_qty = 1, |
| | | StarQuantity = 0, |
| | | EndQuantity = 0, |
| | | agv_tasktype = AGVTaskTypeEnum.TaskType_EmptyPallet.ToString(), |
| | | agv_toaddress = "", |
| | | agv_userid = "ç³»ç»", |
| | | agv_TrayStatus = "EmptyTray", |
| | | agv_Traytype = station.tray_type, |
| | | }; |
| | | agvtaskService.Add(agvtask, true); |
| | | station.location_state = LocationStateEnum.Busy.ToString(); |
| | | stationinfoRepository.Update(station, true); |
| | | WriteDBLog.Success("å建èªå¨å空æéåä»»å¡", $"ä»»å¡ç¼å·ï¼{agvtask.agv_tasknum}ï¼æçä¿¡å·:{PalletSignal},è´§ç©ä¿¡å·:{MaterialSignal}", "PCS"); |
| | | #endregion |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | //WriteDBLog.Error("å建èªå¨å空æä»»å¡", $"{stationCode}ï¼{remark}é误信æ¯ï¼{ex.Message}", "PCS"); |
| | | WriteLog.Write_Log("æ¥éæ¥å¿", "å建èªå¨å空æä»»å¡", "é误信æ¯ï¼", $"{stationCode}ï¼{remark}é误信æ¯ï¼{ex.Message}"); |
| | | WriteLog.Write_Log("æ¥éæ¥å¿", "å建èªå¨å空æéåä»»å¡", "é误信æ¯ï¼", $"{stationCode}ï¼{remark}é误信æ¯ï¼{ex.Message}"); |
| | | } |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | //WriteDBLog.Error("å建èªå¨å空æä»»å¡", $"é误信æ¯ï¼{ex.Message}", "PCS"); |
| | | WriteLog.Write_Log("æ¥éæ¥å¿", "å建èªå¨å空æä»»å¡", "é误信æ¯ï¼", $"é误信æ¯ï¼{ex.Message}"); |
| | | WriteLog.Write_Log("æ¥éæ¥å¿", "å建èªå¨å空æéåä»»å¡", "é误信æ¯ï¼", $"é误信æ¯ï¼{ex.Message}"); |
| | | } |
| | | } |
| | | |
| | |
| | | Idt_mes_headRepository mes_HeadRepository = new dt_mes_headRepository(Context); |
| | | IVV_Mes_WorkinfoRepository workinfoRepository = new VV_Mes_WorkinfoRepository(Context); |
| | | //var mes_Detail = freeDB.Select<dt_mes_detail>().Where(x => x.SN == SN).First(); |
| | | var Mes_Work = workinfoRepository.Find(x => x.SN == SN && x.processCode == "28").FirstOrDefault(); |
| | | var Mes_Work = workinfoRepository.Find(x => x.SN == SN && x.processCode == "28").OrderByDescending(x => x.CreateTime).FirstOrDefault(); |
| | | var mes_Detail = mes_DetailRepository.Find(x => x.SN == SN && x.jobID == Mes_Work.jobID).FirstOrDefault(); |
| | | if (mes_Detail != null) |
| | | { |