| | |
| | | using WIDESEA_Entity.DomainModels; |
| | | using WIDESEA_WCS.IRepositories; |
| | | using WIDESEA_WCS.Jobs; |
| | | using WIDESEA_WCS.JobsPart.Common; |
| | | using WIDESEA_WCS.Repositories; |
| | | using WIDESEA_WCS.WCSClient; |
| | | using WIDESEA_WMS.IRepositories; |
| | |
| | | |
| | | |
| | | ///æ¥æ¾ä¸æåºçè´§ä½ |
| | | var Stations = stationinfoRepository.Find(x => x.area == area_code(number)); |
| | | //ç¼åæ¶æªå¯ç¨ç¦æ¢æ¡æ¶è¿å
¥ |
| | | foreach (var station in Stations) |
| | | { |
| | | if (!station.enable || station.location_state != LocationStateEnum.Stroge.ToString()) |
| | | Gantry_client.WriteByOrder("W_RequestUnload", false, number);//ä¿¡å·ä¸ºfalseæ¡æ¶åæ¢è¿å
¥ |
| | | } |
| | | var Stations = stationinfoRepository.Find(x => x.area == area_code(number)).OrderBy(x => x.lastUpdateTime);//æ ¹æ®æ¶é´å
åæåº |
| | | |
| | | var Station = Stations?.Where(x => x.enable && x.location_state == LocationStateEnum.Stroge.ToString() && x.quantity > 0).OrderBy(x => x.quantity).FirstOrDefault(); |
| | | if (Station != null) |
| | |
| | | WriteDBLog.Error("䏿åº", $"åå
¥æ¡æ¶ä¿¡æ¯ï¼\nW_RequestUnloadï¼false\n\n{Station.stationCode}车轮æ°éä¸SNå·æ°éä¸ä¸è´", "PCS"); |
| | | #endregion |
| | | return; |
| | | //throw new Exception("䏿ä½è½¦è½®æ°éä¸SNå·æ°éä¸ä¸è´ï¼ä¸æä½ç¼å·ï¼" + Station.stationCode); |
| | | } |
| | | var details = plcRepository.Find(x => x.plcdetail_iotype == plc.plcinfo_iotyep && x.plcdetail_number == Station.stationCode).ToList(); |
| | | var PalletSignal = (Int16)DBExtension.Read(details.Where(x => x.plcdetail_name == "R_PalletSignal").First(), client);//读åæçä¿¡å·:1:æ,2æ |
| | | var MaterialSignal = (Int16)DBExtension.Read(details.Where(x => x.plcdetail_name == "R_MaterialSignal").First(), client);//读åè´§ç©ä¿¡å·:1:æ,2æ |
| | | |
| | | var AreaNr = Gantry_client.ReadByOrder<Int16>("W_AreaNr", number);//读åè´§ä½å·ä¿¡æ¯ |
| | | if (PalletSignal == 1 && MaterialSignal == 1) |
| | | { |
| | | 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_Storage_Type", (Int16)1, number); //æçç±»å1-横æ¾;2-ç«æ¾ |
| | | Gantry_client.WriteByOrder("W_Wheel_Type", (Int16)Convert.ToInt16(QueryMateriel(Station.stationType) == null ? QueryMateriel1(Station.stationType).TypeId : QueryMateriel(Station.stationType).TypeId), number);//车轮类å |
| | | Gantry_client.WriteByOrder("W_Wheel_id", SNS[SNS.Length - 1], number);//车轮SNå· |
| | | 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).TypeId == null ? QueryMateriel1(Station.stationType).TypeId : QueryMateriel(Station.stationType).TypeId)}" + |
| | | $"\n车轮SNå·ï¼{SNS[SNS.Length - 1]}\nW_RequestUnloadï¼true", "PCS"); |
| | | #endregion |
| | | if (AreaNr == 0) |
| | | { |
| | | Gantry_client.WriteByOrder("W_Wheel_Type", (Int16)Convert.ToInt16(QueryMateriel(Station.stationType) == null ? QueryMateriel1(Station.stationType).TypeId : QueryMateriel(Station.stationType).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_Storage_Type", (Int16)1, number); //æçç±»å1-横æ¾;2-ç«æ¾ |
| | | Gantry_client.WriteByOrder("W_Wheel_id", SNS[SNS.Length - 1], number);//车轮SNå· |
| | | 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).TypeId == null ? QueryMateriel1(Station.stationType).TypeId : QueryMateriel(Station.stationType).TypeId)}" + |
| | | $"\n车轮SNå·ï¼{SNS[SNS.Length - 1]}\nW_RequestUnloadï¼true", "PCS"); |
| | | #endregion |
| | | } |
| | | } |
| | | else |
| | | { |
| | |
| | | var Date_Vaild = (bool)DBExtension.Read(Gantrydetails.Where(x => x.plcdetail_name == "R_Date_Vaild").First(), Gantry_client);//ä¿¡æ¯ç¡®è®¤ |
| | | if (!Date_Vaild)//ä¿¡æ¯æè¯¯ï¼è®°å½æ¥å¿ |
| | | { |
| | | Gantry_client.WriteByOrder("W_RequestUnload", false, number);//ä¿¡å·ä¸ºfalseæ¡æ¶åæ¢è¿å
¥ |
| | | Station.location_state = LocationStateEnum.Abnormal.ToString(); |
| | | Station.remark = $"æªæ¥è¯¢å°SNå·ï¼{SNS[SNS.Length - 1]}ç订å"; |
| | | stationinfoRepository.Update(Station, true); |
| | | Gantry_client.WriteByOrder("W_RequestUnload", false, number);//ä¿¡å·ä¸ºfalseæ¡æ¶åæ¢è¿å
¥ |
| | | //throw new Exception($"æªæ¥è¯¢å°SNå·ï¼{SNS[SNS.Length - 1]}ç订åï¼ä¸æä½ç¼å·ï¼{Station.stationCode}"); |
| | | WriteDBLog.Error("䏿åºä¿¡æ¯æ¥è¯¢", $"åå
¥æ¡æ¶ä¿¡æ¯ï¼\nW_RequestUnloadï¼false\n\n{Station.stationCode}æªæ¥è¯¢å°SNå·ï¼{SNS[SNS.Length - 1]}ç订å", "PCS"); |
| | | return; |
| | | } |
| | |
| | | if (Station.quantity <= 0) |
| | | { |
| | | Station.stationType = string.Empty; |
| | | //Station.location_state = LocationStateEnum.Empty.ToString(); |
| | | Station.Number = string.Empty; |
| | | Station.heatNumber = string.Empty; |
| | | Station.tray_status = "EmptyTray"; |
| | |
| | | if (count < 1) |
| | | { |
| | | WriteDBLog.Error("åæå®æ", $"䏿ä½ä¿¡æ¯æ´æ°å¤±è´¥ï¼ä¸æä½ç¼å·ï¼{Station.stationCode}", "PCS"); |
| | | //throw new Exception($"䏿ä½ä¿¡æ¯æ´æ°å¤±è´¥ï¼ä¸æä½ç¼å·ï¼{Station.stationCode}"); |
| | | return; |
| | | } |
| | | |
| | | #region æ¸
ç©ºä¿¡æ¯ |
| | | Gantry_client.WriteByOrder("W_AreaNr", (Int16)0, number);//åºåè´§ä½å· |
| | | Gantry_client.WriteByOrder("W_IndexNr", (Int16)0, number);//æçä¸ç第å 个车轮 |
| | | Gantry_client.WriteByOrder("W_Storage_Type", (Int16)0, number); //æçç±»å1-横æ¾;2-ç«æ¾ |
| | | Gantry_client.WriteByOrder("W_Wheel_Type", (Int16)0, number);//车轮类å |
| | | #endregion |
| | | |
| | | Gantry_client.WriteByOrder("W_Storage_update", true, number);//è´§ä½ç¶ææ´æ° |
| | | #region æ¥å¿è®°å½ |
| | | WriteDBLog.Success("åæå®æ", $"åå
¥æ¡æ¶ä¿¡æ¯ï¼\nè´§ä½ç¶ææ´æ°ï¼{true}\nW_RequestUnloadï¼{false}", "PCS"); |
| | | #endregion |
| | | //finished = (bool)DBExtension.Read(Gantrydetails.Where(x => x.plcdetail_name == "R_Unlod_finished").First(), Gantry_client); |
| | | //while (finished) |
| | | //{ |
| | | // finished = (bool)DBExtension.Read(Gantrydetails.Where(x => x.plcdetail_name == "R_Unlod_finished").First(), Gantry_client); |
| | | // Gantry_client.WriteByOrder("W_Storage_update", false, number);//è´§ä½ç¶ææ´æ° |
| | | //} |
| | | } |
| | | //else if (!finished && updatefinished) |
| | | // Gantry_client.WriteByOrder("W_Storage_update", false, number);//è´§ä½ç¶ææ´æ° |
| | | |
| | | PalletSignal = (Int16)DBExtension.Read(details.Where(x => x.plcdetail_name == "R_PalletSignal").First(), client);//读åæçä¿¡å·:1:æ,2æ |
| | | MaterialSignal = (Int16)DBExtension.Read(details.Where(x => x.plcdetail_name == "R_MaterialSignal").First(), client);//读åè´§ç©ä¿¡å·:1:æ,2æ |
| | | if (Station.quantity > 0 && (PalletSignal != 1 || MaterialSignal != 1)) |
| | | { |
| | | Station.location_state = LocationStateEnum.Abnormal.ToString(); |
| | | Station.remark = "车轮æ°é大äº0ï¼å
çµæ£æµæ æçææ è½¦è½®"; |
| | | stationinfoRepository.Update(Station, true); |
| | | client.WriteByOrder("W_AlarmSignal", (Int16)2, number);//æ¥è¦ |
| | | WriteDBLog.Error(number + "æ¥è¦", $"è´§ä½ç¼å·ï¼{Station.stationCode}ï¼é误信æ¯ï¼{Station.remark}", "PCS"); |
| | | } |
| | | else if (Station.quantity < 1 && MaterialSignal == 1) |
| | | { |
| | | Station.location_state = LocationStateEnum.Abnormal.ToString(); |
| | | Station.remark = "车轮æ°éå°äº0ï¼å
çµæ£æµæè½¦è½®"; |
| | | stationinfoRepository.Update(Station, true); |
| | | client.WriteByOrder("W_AlarmSignal", (Int16)2, number);//æ¥è¦ |
| | | WriteDBLog.Error(number + "æ¥è¦", $"è´§ä½ç¼å·ï¼{Station.stationCode}ï¼é误信æ¯ï¼{Station.remark}", "PCS"); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | Gantry_client.WriteByOrder("W_RequestUnload", false, number);//ä¿¡å·ä¸ºfalseæ¡æ¶åæ¢è¿å
¥ |
| | |
| | | catch (Exception ex) |
| | | { |
| | | WriteDBLog.Error("䏿åº", $"é误信æ¯ï¼{ex.Message}", "PCS"); |
| | | //WritePCSLog.LogAdd(requestin.AreaNr.ToString(), respone.success == 1 ? "æå " : "失败", "WMS", "AGV", json, JsonConvert.SerializeObject(respone), remark, "æ£æµçº¿ä¸æåº", ex.Message); |
| | | } |
| | | } |
| | | /// <summary> |
| | |
| | | List<string> stationCodes = new List<string>() { "S01001001", "S01001002", "W01001001", "W01001002", "W01001003" }; |
| | | foreach (var stationCode in stationCodes) |
| | | { |
| | | if (agvtaskService.Find(x => x.agv_fromaddress == stationCode || x.agv_toaddress == stationCode).Any()) |
| | | if (agvtaskService.Find(x => x.agv_fromaddress == stationCode /*|| x.agv_toaddress == stationCode*/).Any()) |
| | | continue; |
| | | var station = stationinfoRepository.Find(x => x.stationCode == stationCode && x.enable).FirstOrDefault(); |
| | | if (station == null) continue; |
| | | var details = plcRepository.Find(x => x.plcdetail_iotype == plc.plcinfo_iotyep && x.plcdetail_number == stationCode).ToList(); |
| | | var PalletSignal = (Int16)DBExtension.Read(details.Where(x => x.plcdetail_name == "R_PalletSignal").First(), client);//读åæçä¿¡å·:1:æ,2æ |
| | | var MaterialSignal = (Int16)DBExtension.Read(details.Where(x => x.plcdetail_name == "R_MaterialSignal").First(), client);//读åè´§ç©ä¿¡å·:1:æ,2æ |
| | | var station = stationinfoRepository.Find(x => x.stationCode == stationCode).FirstOrDefault(); |
| | | if (PalletSignal == 1 && MaterialSignal == 2 && (station.stationCode.Contains("S0100100") ? station.tray_status == "EmptyTray" : true)) |
| | | { |
| | | var area = station.tray_type == "SmallTray" ? "11" : "10"; |
| | | 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).OrderBy(x => x.agv_createtime).FirstOrDefault(); |
| | | 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); |
| | | continue; |
| | | |
| | | } |
| | | var EmptyStation = stationinfoRepository.Find(x => x.area == area && x.quantity < 5 && x.stationCode.Contains("A") && x.location_state != LocationStateEnum.Busy.ToString() && x.enable) |
| | | .OrderByDescending(x => x.line).OrderBy(x => x.column).FirstOrDefault(); |
| | | |
| | | #region 空æå ç |
| | | var EmptyStations = stationinfoRepository.Find(x => x.stationCode.Contains("DD") && x.quantity < 5 && x.enable).ToList(); |
| | | var EmptyStation = EmptyStations.Where(x => x.tray_type == station.tray_type && x.location_state == LocationStateEnum.Stroge.ToString()).FirstOrDefault(); |
| | | if (EmptyStation == null) |
| | | { |
| | | EmptyStation = stationinfoRepository.Find(x => x.area == area && x.quantity < 5 && x.stationCode.Contains(area == "10" ? "D" : "C") && x.location_state == LocationStateEnum.Busy.ToString() && x.enable).OrderByDescending(x => x.column).FirstOrDefault();//æåä¸ä¸ªè´§ä½æä»»å¡åä¸è½çæå
¥åºä»»å¡ |
| | | if (EmptyStation != null) continue; |
| | | EmptyStation = stationinfoRepository.Find(x => x.area == area && x.quantity < 5 && x.stationCode.Contains(area == "10" ? "D" : "C") && x.location_state == LocationStateEnum.Stroge.ToString() && x.enable).OrderByDescending(x => x.column).FirstOrDefault();//æ¾æå¤é¢æ²¡å 满5个çè´§ä½ |
| | | if (EmptyStation == null) |
| | | EmptyStation = stationinfoRepository.Find(x => x.area == area && x.quantity < 5 && x.stationCode.Contains(area == "10" ? "D" : "C") && x.location_state == LocationStateEnum.Empty.ToString() && x.enable).OrderBy(x => x.column).FirstOrDefault(); |
| | | } |
| | | EmptyStation = EmptyStations.Where(x => x.location_state == LocationStateEnum.Empty.ToString()).FirstOrDefault(); |
| | | #endregion |
| | | |
| | | if (EmptyStation == null)//æ¥æ¾åºå
空æç |
| | | EmptyStation = GetStation.EmptyPalletStation(area); |
| | | |
| | | |
| | | if (EmptyStation != null) |
| | | { |
| | |
| | | agv_fromaddress = station.stationCode, |
| | | agv_id = Guid.NewGuid(), |
| | | agv_tasknum = IdenxManager.GetTaskNo("KH-", "WMS"), |
| | | agv_grade = 1, |
| | | agv_grade = station.stationCode.Contains("S0100100") ? 3 : 1, |
| | | agv_createtime = DateTime.Now, |
| | | agv_taskstate = "Create", |
| | | //agv_materielid = station.stationType, |
| | |
| | | { |
| | | try |
| | | { |
| | | List<string> names = new List<string>() { "1åå
䏿åº", "2åå
䏿åº", "3åå
䏿åº", "䏿åº" }; |
| | | List<string> names = new List<string>() { "1åå
䏿åº", "2åå
䏿åº", "3åå
䏿åº" };/*, "䏿åº"*/ |
| | | foreach (var name in names) |
| | | { |
| | | VOLContext Context = new VOLContext(); |
| | |
| | | Station.remark = "车轮æ°é大äº0ï¼å
çµæ£æµæ æçææ è½¦è½®"; |
| | | stationinfoRepository.Update(Station, true); |
| | | client.WriteByOrder("W_AlarmSignal", (Int16)2, name);//æ¥è¦ |
| | | WriteDBLog.Error(name + "æ¥è¦", $"è´§ä½ç¼å·ï¼{Station.stationCode}ï¼é误信æ¯ï¼{Station.remark}", "PCS"); |
| | | continue; |
| | | } |
| | | if (Station.location_state == LocationStateEnum.Stroge.ToString() && PalletSignal != 1) |
| | | { |
| | | Station.location_state = LocationStateEnum.Abnormal.ToString(); |
| | | Station.remark = "è´§ä½æè´§ï¼å
çµæ£æµæ æç"; |
| | | Station.remark = "å
çµæ£æµæ æç"; |
| | | stationinfoRepository.Update(Station, true); |
| | | client.WriteByOrder("W_AlarmSignal", (Int16)2, name);//æ¥è¦ |
| | | WriteDBLog.Error(name + "æ¥è¦", $"è´§ä½ç¼å·ï¼{Station.stationCode}ï¼é误信æ¯ï¼{Station.remark}", "PCS"); |
| | | continue; |
| | | } |
| | | if (Station.location_state == LocationStateEnum.Empty.ToString() && (PalletSignal == 1 || MaterialSignal == 1))//ç³»ç»è´§ä½ä¸ºç©ºï¼å
çµæ£æµææ |
| | | { |
| | | Station.location_state = LocationStateEnum.Abnormal.ToString(); |
| | | Station.remark = "è´§ä½æ è´§ï¼å
çµæ£æµææ"; |
| | | Station.remark = "å
çµæ£æµææ"; |
| | | stationinfoRepository.Update(Station, true); |
| | | client.WriteByOrder("W_AlarmSignal", (Int16)2, name);//æ¥è¦ |
| | | WriteDBLog.Error(name + "æ¥è¦", $"è´§ä½ç¼å·ï¼{Station.stationCode}ï¼é误信æ¯ï¼{Station.remark}", "PCS"); |
| | | continue; |
| | | } |
| | | //if (Station.quantity < 1 && MaterialSignal == 1)//ç³»ç»è´§ä½æ 车轮ï¼å
çµæ£æµæè½¦è½® |
| | |
| | | VOLContext Context = new VOLContext(); |
| | | Idt_mes_detailRepository mes_DetailRepository = new dt_mes_detailRepository(Context); |
| | | 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_Detail = mes_DetailRepository.Find(x => x.SN == SN).FirstOrDefault(); |
| | | var Mes_Work = workinfoRepository.Find(x => x.SN == SN && x.processCode == "28").FirstOrDefault(); |
| | | var mes_Detail = mes_DetailRepository.Find(x => x.SN == SN && x.jobID == Mes_Work.jobID).FirstOrDefault(); |
| | | if (mes_Detail != null) |
| | | { |
| | | mes_Detail.Status = "ä¸çº¿"; |