| | |
| | | |
| | | public class AGVGteaddress |
| | | { |
| | | |
| | | /// <summary> |
| | | /// ä½ä¸ä»»å¡å· |
| | | /// </summary> |
| | | public string TASK_NO { get; set; } |
| | | /// <summary> |
| | | /// è´§ä½å· |
| | | /// </summary> |
| | |
| | | public static Signal GetSignal(string address) |
| | | { |
| | | Signal signal = new Signal(); |
| | | AGVGteaddress gteaddress=new AGVGteaddress(); |
| | | AGVGteaddress gteaddress = new AGVGteaddress(); |
| | | try |
| | | { |
| | | if (string.IsNullOrEmpty(address) || address == "null") |
| | | throw new Exception("æªè·åå°è¯·æ±åæ°æ°æ®"); |
| | | gteaddress = JsonConvert.DeserializeObject<AGVGteaddress>(address); |
| | | gteaddress = JsonConvert.DeserializeObject<AGVGteaddress>(address); |
| | | |
| | | var Pipeline_client = PLCClient.Clients.FirstOrDefault(t => t.PLCName == "龿¡æº"); |
| | | if (Pipeline_client == null) throw new Exception("龿¡æºè°åº¦æå¡æªå¼å¯ï¼"); |
| | |
| | | { |
| | | signal.Message = ex.Message; |
| | | } |
| | | WritePCSLog.LogAdd(address, signal.success == 1 ? "æå " : "失败", "PCS", "AGV", address, JsonConvert.SerializeObject(signal), $"AGVè·å{gteaddress.address}å
çµä¿¡å·", "GetSignal", signal.Message); |
| | | WritePCSLog.LogAdd(address, signal.success == 1 ? "æå " : "失败", "PCS", "AGV", address, JsonConvert.SerializeObject(signal), $"{gteaddress.TASK_NO}çAGVè·å{gteaddress.address}å
çµä¿¡å·", "GetSignal", signal.Message); |
| | | return signal; |
| | | } |
| | | } |
| | |
| | | var NGStation = "X01001003"; |
| | | if (name == "2åå
䏿åº") NGStation = "X02001003"; |
| | | if (name == "3åå
䏿åº") NGStation = "X03001002"; |
| | | #region MyRegion |
| | | //var Wheel_Type = DBExtension.Read(details.Where(x => x.plcdetail_name == "R_Wheel_Type").First(), client);//车轮类å |
| | | //var Wheel_id = client.ReadByOrder<string>("R_Wheel_id", name);//车轮SNå· |
| | | //if (string.IsNullOrEmpty(Wheel_id)) continue; |
| | | ////var Wheel_id = DBExtension.Read(details.Where(x => x.plcdetail_name == "R_Wheel_id").First(), client).ToString(); |
| | | |
| | | //var mes_Detail = mes_DetailRepository.FindFirst(x => x.SN == Wheel_id); |
| | | //if (mes_Detail == null) |
| | | //{ |
| | | // #region æ¥å¿è®°å½ |
| | | // WriteDBLog.Error(name, $"è¯»åæ¡æ¶ä¿¡æ¯ï¼\n车轮SNï¼{Wheel_id}\n\næªæ¥è¯¢å°å·¥å详æ
", "PCS"); |
| | | // #endregion |
| | | // continue; |
| | | //} |
| | | //var mes_Head = mes_HeadRepository.FindFirst(x => x.jobID == mes_Detail.jobID); |
| | | //if (mes_Head == null) |
| | | //{ |
| | | // #region æ¥å¿è®°å½ |
| | | // WriteDBLog.Error(name, $"è¯»åæ¡æ¶ä¿¡æ¯ï¼\n车轮SNï¼{Wheel_id}\n\næªæ¥è¯¢å°å·¥å头表", "PCS"); |
| | | // #endregion |
| | | // continue; |
| | | //} |
| | | #endregion |
| | | |
| | | var finished = (bool)DBExtension.Read(details.Where(x => x.plcdetail_name == "R_load_finished").First(), client);//æ¾æå®æ |
| | | var updatefinished = (bool)DBExtension.Read(details.Where(x => x.plcdetail_name == "W_Storage_update").First(), client);//è´§ä½ç¶ææ´æ° |
| | | |
| | | #region è´§ä½ç¶ææ´æ°å¤ä½ |
| | | //if (!finished && updatefinished) |
| | | //{ |
| | | // client.WriteByOrder("W_Storage_update", false, name);//è´§ä½ç¶ææ´æ° |
| | | // #region æ¥å¿è®°å½ |
| | | // WriteDBLog.Success(name + "è´§ä½ç¶ææ´æ°å¤ä½", $"è¯»åæ¡æ¶ä¿¡æ¯ï¼\nR_load_finishedï¼{finished}\n\nåå
¥æ¡æ¶ä¿¡æ¯ï¼\nW_Storage_updateï¼false", "PCS"); |
| | | // #endregion |
| | | //} |
| | | if (!finished && updatefinished) |
| | | { |
| | | client.WriteByOrder("W_Storage_update", false, name);//è´§ä½ç¶ææ´æ° |
| | | #region æ¥å¿è®°å½ |
| | | //WriteDBLog.Success(name + "è´§ä½ç¶ææ´æ°å¤ä½", $"è¯»åæ¡æ¶ä¿¡æ¯ï¼\nR_load_finishedï¼{finished}\n\nåå
¥æ¡æ¶ä¿¡æ¯ï¼\nW_Storage_updateï¼{false}", "PCS"); |
| | | WriteLog.Write_Log(name + "æ¾æå®æ", name + "è´§ä½ç¶ææ´æ°ä¿¡å·å¤ä½", "æåï¼", |
| | | $"è¯»åæ¡æ¶ä¿¡æ¯ï¼\næ¾æå®æä¿¡å·ï¼{finished}\n\nåå
¥æ¡æ¶ä¿¡æ¯ï¼\nè´§ä½ç¶ææ´æ°ä¿¡å·ï¼{false}"); |
| | | #endregion |
| | | } |
| | | #endregion |
| | | |
| | | |
| | | if (finished && !updatefinished) |
| | | { |
| | |
| | | #endregion |
| | | continue; |
| | | } |
| | | #region MyRegion |
| | | //var Detail = mes_DetailRepository.FindFirst(x => x.SN == Wheel_SN); |
| | | //if (Detail == null) |
| | | //{ |
| | | // #region æ¥å¿è®°å½ |
| | | // WriteDBLog.Error(name, $"è¯»åæ¡æ¶ä¿¡æ¯ï¼\n车轮SNå·ï¼{Wheel_SN}\n\næªæ¥è¯¢å°å·¥å详æ
", "PCS"); |
| | | // #endregion |
| | | // continue; |
| | | //} |
| | | //var Head = mes_HeadRepository.FindFirst(x => x.jobID == Detail.jobID && x.processCode == "17"); |
| | | //if (Head == null) |
| | | //{ |
| | | // #region æ¥å¿è®°å½ |
| | | // WriteDBLog.Error(name, $"è¯»åæ¡æ¶ä¿¡æ¯ï¼\n车轮SNå·ï¼{Wheel_SN}\n\næªæ¥è¯¢å°å·¥å头表{Detail.jobID}", "PCS"); |
| | | // #endregion |
| | | // continue; |
| | | //} |
| | | #endregion |
| | | |
| | | #endregion |
| | | |
| | |
| | | continue; |
| | | } |
| | | |
| | | #region 夿åºåå·æ¯å¦ä¸è´ |
| | | var area = client.ReadByOrder<Int16>("place_prog", name);//æ¾æå®æçåºåå· |
| | | |
| | | if (AreaNr != area) |
| | | { |
| | | Pipeline_client.WriteByOrder("W_AlarmSignal", (Int16)2, name);//æ¥è¦ |
| | | //WriteDBLog.Error(name + "æ¥è¦", $"PCSåºåå·ï¼{AreaNr}ï¼æ¡æ¶åºåå·ï¼{area}é误信æ¯ï¼PCSåºåå·ä¸æ¡æ¶åºåå·ä¸ä¸è´ï¼", "PCS"); |
| | | WriteLog.Write_Log(name + "æ¾æå®æåºé", Wheel_SN, "夿åºåå·æ¯å¦ä¸è´", $"PCSåºåå·ï¼{AreaNr}ï¼\næ¡æ¶åºåå·ï¼{area}\né误信æ¯ï¼PCSåºåå·ä¸æ¡æ¶åºåå·ä¸ä¸è´ï¼"); |
| | | continue; |
| | | } |
| | | #endregion |
| | | |
| | | var areaCode = PipelineJob.area_code(name); //æ ¹æ®ä¸æå£åå
åè·ååºå代ç |
| | | var station = stationinfoRepository.FindFirst(x => x.area == areaCode && x.stationCode.Substring(x.stationCode.Length - 1, 1) == AreaNr.ToString()); |
| | | if (station.quantity >= 5) |
| | | throw new Exception($"䏿ä½ä¿¡æ¯æ´æ°å¤±è´¥ï¼ä¸æä½è½¦è½®æ°é大äº5ï¼{station.stationCode}"); |
| | | //station.bindSN = station.bindSN == string.Empty ? Wheel_id : station.bindSN + "," + Wheel_id; |
| | | if (!string.IsNullOrEmpty(station.bindSN)) |
| | | var station = stationinfoRepository.Find(x => x.area == areaCode && x.stationCode.Substring(x.stationCode.Length - 1, 1) == AreaNr.ToString()).FirstOrDefault(); |
| | | if (station != null) |
| | | { |
| | | if (station.bindSN.Contains(Wheel_SN)) |
| | | throw new Exception($"{station.stationCode}å·²åå¨è½¦è½®SNå·ï¼{Wheel_SN}"); |
| | | if (station.quantity >= 5) |
| | | { |
| | | Pipeline_client.WriteByOrder("W_AlarmSignal", (Int16)2, name);//æ¥è¦ |
| | | WriteLog.Write_Log(name + "æ¾æå®æåºé", Wheel_SN, "车轮æ°é已满ï¼", $"åºåå·ï¼{AreaNr}ï¼\n车轮æ°ï¼{station.quantity}\né误信æ¯ï¼åºåå·è½¦è½®æ°é已满ï¼"); |
| | | } |
| | | |
| | | #region å¤æè½¦è½®æ°éæ¯å¦ä¸è´ |
| | | var quantity = client.ReadByOrder<Int16>("pos_prog", name);//æ¡æ¶è®°å½ç车轮æ°é |
| | | |
| | | if (quantity != station.quantity + 1) |
| | | { |
| | | Pipeline_client.WriteByOrder("W_AlarmSignal", (Int16)2, name);//æ¥è¦ |
| | | WriteLog.Write_Log(name + "æ¾æå®æåºé", Wheel_SN, "å¤æè½¦è½®æ°éæ¯å¦ä¸è´", $"åºåå·ï¼{AreaNr}ï¼\næ¡æ¶è½¦è½®æ°ï¼{quantity}\nPCS车轮æ°ï¼{station.quantity + 1}\né误信æ¯ï¼PCSåºåå·ä¸æ¡æ¶åºåå·ä¸ä¸è´ï¼"); |
| | | continue; |
| | | } |
| | | #endregion |
| | | |
| | | if (!string.IsNullOrEmpty(station.bindSN)) |
| | | { |
| | | if (station.bindSN.Contains(Wheel_SN)) |
| | | throw new Exception($"{station.stationCode}å·²åå¨è½¦è½®SNå·ï¼{Wheel_SN}"); |
| | | } |
| | | |
| | | station.bindSN = string.IsNullOrEmpty(station.bindSN) ? Wheel_SN : station.bindSN + "," + Wheel_SN; |
| | | station.billetID = string.IsNullOrEmpty(station.billetID) ? Mes_Work.billetID.ToString() : station.billetID + "," + Mes_Work.billetID; |
| | | station.quantity++; |
| | | if (station.quantity == 1) |
| | | { |
| | | station.stationType = Mes_Work.drawingNo; |
| | | station.Number = Mes_Work.workOrder; |
| | | station.heatNumber = Mes_Work.heatID; |
| | | station.tray_status = "StrogeTray"; |
| | | } |
| | | |
| | | var count = stationinfoRepository.Update(station, true); |
| | | if (count < 1) |
| | | throw new Exception($"䏿ä½ä¿¡æ¯æ´æ°å¤±è´¥ï¼ä¸æä½ç¼å·ï¼{station.stationCode}"); |
| | | |
| | | #region æ¸
ç©ºç»æ¡æ¶çä¸æä¿¡æ¯ |
| | | client.WriteByOrder("W_IndexNr", (Int16)0, name);//æçä¸ç第å 个车轮 |
| | | client.WriteByOrder("W_Storage_Type", (Int16)0, name);//æçç±»å1-横æ¾;2-ç«æ¾(ææ¶åªææ¨ªæ¾æç) |
| | | client.WriteByOrder("W_AreaNr", (Int16)0, name);//åºåè´§ä½å· |
| | | client.WriteByOrder("W_Storage_update", true, name);//è´§ä½ç¶ææ´æ° |
| | | WriteLog.Write_Log(name + "æ¾æå®æ", Wheel_SN, "æåï¼", |
| | | $"è¯»åæ¡æ¶ä¿¡æ¯ï¼\næ¾æå®æä¿¡å·ï¼{finished}\n车轮SNï¼{Wheel_SN}\nè½®åIDï¼{WheelType}\n䏿ä½å·ï¼{AreaNr}\n\n" + |
| | | $"å¤çåå
¥æ¡æ¶ä¿¡æ¯ï¼\nåºåè´§ä½å·ï¼{0}\næçä¸ç第å 个车轮ï¼{0}\næçç±»åï¼{0}\n\n" + |
| | | $"åå
¥æ¡æ¶ä¿¡æ¯ï¼\nè´§ä½ç¶ææ´æ°ä¿¡å·ï¼{true}\næ¯å¦å
è®¸ä¸æï¼{false}"); |
| | | //WriteDBLog.Success(name + "æ¡æ¶ä¸æå®æ", |
| | | // $"è¯»åæ¡æ¶ä¿¡æ¯ï¼\nR_load_finishedï¼{finished}\n车轮SNï¼{Wheel_SN}\nè½®åIDï¼{WheelType}\n䏿ä½å·ï¼{AreaNr}\n\n" + |
| | | // $"å¤çåå
¥æ¡æ¶ä¿¡æ¯ï¼\nW_AreaNrï¼{0}\nW_IndexNrï¼{0}\nW_Storage_Typeï¼{0}\n\n" + |
| | | // $"åå
¥æ¡æ¶ä¿¡æ¯ï¼\nW_Storage_updateï¼{true}\nW_Enabl_Loadï¼{false}", "PCS"); |
| | | #endregion |
| | | |
| | | #region ä¿®æ¹å·¥åç¶æ |
| | | var Detail = mes_DetailRepository.FindFirst(x => x.jobID == Mes_Work.jobID && x.SN == Mes_Work.SN); |
| | | Detail.Status = "ä¸çº¿"; |
| | | Detail.FinishTime = DateTime.Now; |
| | | count = mes_DetailRepository.Update(Detail, true); |
| | | if (count < 1) |
| | | throw new Exception($"å·¥ååè¡¨ä¿¡æ¯æ´æ°å¤±è´¥ï¼è½¦è½®SNå·ï¼{Detail.SN}"); |
| | | var Head = mes_HeadRepository.FindFirst(x => x.jobID == Detail.jobID); |
| | | Head.finishNum = Head.finishNum + 1; |
| | | count = mes_HeadRepository.Update(Head, true); |
| | | if (count < 1) |
| | | throw new Exception($"å·¥åå¤´è¡¨ä¿¡æ¯æ´æ°å¤±è´¥ï¼å·¥åå·ï¼{Head.jobID}"); |
| | | #endregion |
| | | } |
| | | |
| | | station.bindSN = string.IsNullOrEmpty(station.bindSN) ? Wheel_SN : station.bindSN + "," + Wheel_SN; |
| | | station.billetID = string.IsNullOrEmpty(station.billetID) ? Mes_Work.billetID.ToString() : station.billetID + "," + Mes_Work.billetID; |
| | | station.quantity++; |
| | | if (station.quantity == 1) |
| | | { |
| | | station.stationType = Mes_Work.drawingNo; |
| | | station.Number = Mes_Work.workOrder; |
| | | station.heatNumber = Mes_Work.heatID; |
| | | station.tray_status = "StrogeTray"; |
| | | } |
| | | //else if (station.stationCode == NGStation) |
| | | //{ |
| | | // station.heatNumber = string.IsNullOrEmpty(station.heatNumber) ? Mes_Work.heatID : station.heatNumber + "," + Mes_Work.heatID; |
| | | //} |
| | | |
| | | var count = stationinfoRepository.Update(station, true); |
| | | if (count < 1) |
| | | throw new Exception($"䏿ä½ä¿¡æ¯æ´æ°å¤±è´¥ï¼ä¸æä½ç¼å·ï¼{station.stationCode}"); |
| | | |
| | | #region æ¸
ç©ºç»æ¡æ¶çä¸æä¿¡æ¯ |
| | | client.WriteByOrder("W_AreaNr", (Int16)0, name);//åºåè´§ä½å· |
| | | client.WriteByOrder("W_IndexNr", (Int16)0, name);//æçä¸ç第å 个车轮 |
| | | client.WriteByOrder("W_Storage_Type", (Int16)0, name);//æçç±»å1-横æ¾;2-ç«æ¾(ææ¶åªææ¨ªæ¾æç) |
| | | client.WriteByOrder("W_Storage_update", true, name);//è´§ä½ç¶ææ´æ° |
| | | WriteLog.Write_Log(name + "æ¾æå®æ", Wheel_SN, "æåï¼", |
| | | $"è¯»åæ¡æ¶ä¿¡æ¯ï¼\næ¾æå®æä¿¡å·ï¼{finished}\n车轮SNï¼{Wheel_SN}\nè½®åIDï¼{WheelType}\n䏿ä½å·ï¼{AreaNr}\n\n" + |
| | | $"å¤çåå
¥æ¡æ¶ä¿¡æ¯ï¼\nåºåè´§ä½å·ï¼{0}\næçä¸ç第å 个车轮ï¼{0}\næçç±»åï¼{0}\n\n" + |
| | | $"åå
¥æ¡æ¶ä¿¡æ¯ï¼\nè´§ä½ç¶ææ´æ°ä¿¡å·ï¼{true}\næ¯å¦å
è®¸ä¸æï¼{false}"); |
| | | //WriteDBLog.Success(name + "æ¡æ¶ä¸æå®æ", |
| | | // $"è¯»åæ¡æ¶ä¿¡æ¯ï¼\nR_load_finishedï¼{finished}\n车轮SNï¼{Wheel_SN}\nè½®åIDï¼{WheelType}\n䏿ä½å·ï¼{AreaNr}\n\n" + |
| | | // $"å¤çåå
¥æ¡æ¶ä¿¡æ¯ï¼\nW_AreaNrï¼{0}\nW_IndexNrï¼{0}\nW_Storage_Typeï¼{0}\n\n" + |
| | | // $"åå
¥æ¡æ¶ä¿¡æ¯ï¼\nW_Storage_updateï¼{true}\nW_Enabl_Loadï¼{false}", "PCS"); |
| | | #endregion |
| | | |
| | | |
| | | //client.WriteByOrder("W_Enabl_Load", false, name);//æ¯å¦å
许 |
| | | |
| | | #region ä¿®æ¹å·¥åç¶æ |
| | | var Detail = mes_DetailRepository.FindFirst(x => x.jobID == Mes_Work.jobID && x.SN == Mes_Work.SN); |
| | | Detail.Status = "ä¸çº¿"; |
| | | Detail.FinishTime = DateTime.Now; |
| | | count = mes_DetailRepository.Update(Detail, true); |
| | | if (count < 1) |
| | | throw new Exception($"å·¥ååè¡¨ä¿¡æ¯æ´æ°å¤±è´¥ï¼è½¦è½®SNå·ï¼{Detail.SN}"); |
| | | var Head = mes_HeadRepository.FindFirst(x => x.jobID == Detail.jobID); |
| | | Head.finishNum = Head.finishNum + 1; |
| | | count = mes_HeadRepository.Update(Head, true); |
| | | if (count < 1) |
| | | throw new Exception($"å·¥åå¤´è¡¨ä¿¡æ¯æ´æ°å¤±è´¥ï¼å·¥åå·ï¼{Head.jobID}"); |
| | | #endregion |
| | | |
| | | #region æ¥å¿è®°å½ |
| | | //WriteDBLog.Success(name + "æ¾æå®æ", $"è¯»åæ¡æ¶ä¿¡æ¯ï¼\n车轮SNï¼{Wheel_id}\nè½®åIDï¼{Wheel_Type}\n䏿ä½å·ï¼{AreaNr}" + |
| | | // $"\n\nåå
¥æ¡æ¶ä¿¡æ¯ï¼\nW_Storage_updateï¼true" + $"\nW_Enabl_Loadï¼false", "PCS"); |
| | | #endregion |
| | | } |
| | | |
| | | #region è´§ä½ç¶ææ´æ°å¤ä½ |
| | | finished = (bool)DBExtension.Read(details.Where(x => x.plcdetail_name == "R_load_finished").First(), client);//æ¾æå®æ |
| | | updatefinished = (bool)DBExtension.Read(details.Where(x => x.plcdetail_name == "W_Storage_update").First(), client);//è´§ä½ç¶ææ´æ° |
| | | if (!finished && updatefinished) |
| | | { |
| | | client.WriteByOrder("W_Storage_update", false, name);//è´§ä½ç¶ææ´æ° |
| | | #region æ¥å¿è®°å½ |
| | | //WriteDBLog.Success(name + "è´§ä½ç¶ææ´æ°å¤ä½", $"è¯»åæ¡æ¶ä¿¡æ¯ï¼\nR_load_finishedï¼{finished}\n\nåå
¥æ¡æ¶ä¿¡æ¯ï¼\nW_Storage_updateï¼{false}", "PCS"); |
| | | WriteLog.Write_Log(name + "æ¾æå®æ", name + "è´§ä½ç¶ææ´æ°ä¿¡å·å¤ä½", "æåï¼", |
| | | $"è¯»åæ¡æ¶ä¿¡æ¯ï¼\næ¾æå®æä¿¡å·ï¼{finished}\n\nåå
¥æ¡æ¶ä¿¡æ¯ï¼\nè´§ä½ç¶ææ´æ°ä¿¡å·ï¼{false}"); |
| | | #endregion |
| | | } |
| | | #endregion |
| | | |
| | | var Request = (bool)DBExtension.Read(details.Where(x => x.plcdetail_name == "R_Request_Load").First(), client); |
| | | if (!Request) continue; |
| | |
| | | WriteLog.Write_Log(name + "ç³è¯·æ¾æå¼å¸¸", Wheel_id, "æ¥è¯¢æºå 工工å", $"è¯»åæ¡æ¶ä¿¡æ¯ï¼\n车轮SNå·ï¼{Wheel_id}æªæ¥è¯¢å°å·¥åä¿¡æ¯\nåå
¥æ¡æ¶ä¿¡æ¯ï¼\næ¯å¦å
è®¸ä¸æï¼{false}"); |
| | | } |
| | | |
| | | #region MyRegion |
| | | //var mes_Detail = mes_DetailRepository.FindFirst(x => x.SN == Wheel_id); |
| | | //if (mes_Detail == null) |
| | | //{ |
| | | // #region æ¥å¿è®°å½ |
| | | // client.WriteByOrder("W_Enabl_Load", false, name);//ä¿¡å·ä¸ºfalseæ¡æ¶åæ¢è¿å
¥ |
| | | // WriteDBLog.Error(name, $"è¯»åæ¡æ¶ä¿¡æ¯ï¼\n车轮SNï¼{Wheel_id}\n\næªæ¥è¯¢å°å·¥å详æ
", "PCS"); |
| | | // #endregion |
| | | // continue; |
| | | //} |
| | | //var mes_Head = mes_HeadRepository.FindFirst(x => x.jobID == mes_Detail.jobID); |
| | | //if (mes_Head == null) |
| | | //{ |
| | | // #region æ¥å¿è®°å½ |
| | | // client.WriteByOrder("W_Enabl_Load", false, name);//ä¿¡å·ä¸ºfalseæ¡æ¶åæ¢è¿å
¥ |
| | | // WriteDBLog.Error(name, $"è¯»åæ¡æ¶ä¿¡æ¯ï¼\n车轮SNï¼{Wheel_id}\n\næªæ¥è¯¢å°å·¥å头表", "PCS"); |
| | | // #endregion |
| | | // continue; |
| | | //} |
| | | #endregion |
| | | |
| | | #endregion |
| | | |
| | | |
| | | var Stations = stationinfoRepository.Find(x => x.area == PipelineJob.area_code(name)).OrderBy(x => x.lastUpdateTime).ToList(); |
| | | |
| | | |
| | | |
| | | //foreach (var station in Stations) //ä»»ä½ä¸ä¸ªä¸æä½ä¸ºç©ºæç¦ç¨æ¶,é½ä¼åæ¢æ¡æ¶ |
| | | //{ |
| | | // if (!station.enable || station.location_state == LocationStateEnum.Empty.ToString()) |
| | | // client.WriteByOrder("W_Enabl_Load", false, name);//ä¿¡å·ä¸ºfalseæ¡æ¶åæ¢è¿å
¥ |
| | | //} |
| | | #region 䏿使¯å¦ä¸ºç©ºç¶æåæ¥ç»æ¡æ¶ |
| | | foreach (var station in Stations) |
| | | { |
| | | client.WriteByOrder(station.stationCode, station.location_state != LocationStateEnum.Stroge.ToString(), name); |
| | | } |
| | | #endregion |
| | | |
| | | #region MyRegion |
| | | //var currentAreaNr = (Int16)DBExtension.Read(details.Where(x => x.plcdetail_name == "W_Are00aNr").First(), client); |
| | |
| | | WriteLog.Write_Log(name + "ç³è¯·æ¾æ", Wheel_id, "ç³è¯·æ¾æ", $"è¯»åæ¡æ¶ä¿¡æ¯ï¼\n车轮SNï¼{Wheel_id}\nè½®åIDï¼{Wheel_Type}\nè½¦è½®ç¶æï¼{PartStatus}\næ¯å¦è¿å
¥ä¸æåºï¼{load_zone}"); |
| | | if (load_zone) continue; |
| | | #endregion |
| | | |
| | | #region åæ ¼ |
| | | if ((Int16)PartStatus == 1) |
| | | { |
| | | dt_stationinfo Stationinfo = null; |
| | |
| | | && x.location_state == LocationStateEnum.Stroge.ToString() |
| | | && x.quantity < 5 |
| | | && x.stationType == Work.drawingNo |
| | | //&& x.tray_type == ((wheel == null ? wheel1.e : wheel.e) < 1100 ? "SmallTray" : "LargeTray") |
| | | && x.Number == Work.workOrder |
| | | && x.heatNumber == Work.heatID) |
| | | .OrderByDescending(x => x.quantity) |
| | |
| | | && x.location_state == LocationStateEnum.Stroge.ToString() |
| | | && x.quantity < 5 |
| | | && x.stationType == Work.drawingNo |
| | | //&& x.tray_type == ((wheel == null ? wheel1.e : wheel.e) < 1100 ? "SmallTray" : "LargeTray") |
| | | && x.Number == Work.workOrder) |
| | | .OrderByDescending(x => x.quantity) |
| | | .FirstOrDefault(); |
| | |
| | | |
| | | if (Stationinfo == null) |
| | | { |
| | | |
| | | #region 䏿使¡ä»¶ä¸å¹é
ç´æ¥è§¦åå
¥åºä»»å¡ |
| | | //var stationinfos = Stations.Where(x => x.enable && x.stationCode != NGStation && x.location_state == LocationStateEnum.Stroge.ToString() && x.quantity > 0).ToList(); |
| | | //foreach (var stationinfo in stationinfos) |
| | | //{ |
| | | // agvtask(stationinfoRepository, stationinfo, (wheel == null ? wheel1.e : wheel.e), name == "3åå
䏿åº" ? "TaskType_OutsourceInbound" : "TaskType_Inbound"); |
| | | //} |
| | | #endregion |
| | | |
| | | |
| | | #region 触åNGä»»å¡ |
| | | var NG = Stations.Where(x => x.enable && x.stationCode == NGStation && x.location_state == LocationStateEnum.Stroge.ToString() && x.quantity > 0).FirstOrDefault(); |
| | | if (NG != null) |
| | |
| | | |
| | | Stationinfo = Stations.Where(x => x.enable && x.stationCode != NGStation && x.location_state == LocationStateEnum.Stroge.ToString() && x.quantity == 0).FirstOrDefault(); |
| | | |
| | | #region MyRegion |
| | | //var stationinfo = Stations.Where(x => x.enable && x.stationCode != NGStation && x.location_state == LocationStateEnum.Stroge.ToString() && x.quantity > 0).FirstOrDefault(); |
| | | //if (stationinfo != null) |
| | | //{ |
| | | // agvtask(stationinfoRepository, mes_Head, stationinfo, (wheel == null ? wheel1.e : wheel.e), name == "3åå
䏿åº" ? "TaskType_OutsourceInbound" : "TaskType_Inbound"); |
| | | //} |
| | | #endregion |
| | | } |
| | | |
| | | if (Stationinfo != null) |
| | |
| | | #endregion |
| | | |
| | | #region æçç±»åä¸ä¸è´éæ´æ¢æç |
| | | //if (Stationinfo.tray_type != ((wheel == null ? wheel1.e : wheel.e) < 1100 ? "SmallTray" : "LargeTray")) |
| | | if (Stationinfo.tray_type != "LargeTray" && (wheel == null ? wheel1.e : wheel.e) > 1100) |
| | | { |
| | | client.WriteByOrder("W_Enabl_Load", false, name);//ä¿¡å·ä¸ºfalseæ¡æ¶åæ¢è¿å
¥ |
| | |
| | | |
| | | var MaterialSignal = (Int16)DBExtension.Read(Pipelinedetails.Where(x => x.plcdetail_name == "R_MaterialSignal").First(), Pipeline_client);//读åè´§ç©ä¿¡å·:1:æ,2æ |
| | | |
| | | //var Wheel_id = client.ReadByOrder<string>("R_Wheel_id", name); |
| | | if (PalletSignal == 1) |
| | | { |
| | | List<string> list = new List<string>(); |
| | |
| | | } |
| | | |
| | | #region è´§ä½æ°éä¸å
çµä¸å¹é
ï¼æ¥è¦ |
| | | if (list.Count > 0 && MaterialSignal != 1) |
| | | { |
| | | client.WriteByOrder("W_Enabl_Load", false, name);//ä¿¡å·ä¸ºfalseæ¡æ¶åæ¢è¿å
¥ |
| | | Pipeline_client.WriteByOrder("W_AlarmSignal", (Int16)2, name);//æ¥è¦ |
| | | Stationinfo.location_state = LocationStateEnum.Abnormal.ToString(); |
| | | Stationinfo.remark = "车轮æ°éä¸å
çµä¸å¹é
"; |
| | | stationinfoRepository.Update(Stationinfo, true); |
| | | WriteDBLog.Error(name + "æ¥è¦", $"è´§ä½ç¼å·ï¼{Stationinfo.stationCode}ï¼é误信æ¯ï¼{Stationinfo.remark}", "PCS"); |
| | | //WriteDBLog.Error(name+"ç³è¯·ä¸æ",$"{Stationinfo.stationCode}çè´§ä½","PCS"); |
| | | } |
| | | else if (list.Count < 1 && MaterialSignal == 1) |
| | | { |
| | | client.WriteByOrder("W_Enabl_Load", false, name);//ä¿¡å·ä¸ºfalseæ¡æ¶åæ¢è¿å
¥ |
| | | Pipeline_client.WriteByOrder("W_AlarmSignal", (Int16)2, name);//æ¥è¦ |
| | | Stationinfo.location_state = LocationStateEnum.Abnormal.ToString(); |
| | | Stationinfo.remark = "车轮æ°éä¸å
çµä¸å¹é
"; |
| | | stationinfoRepository.Update(Stationinfo, true); |
| | | WriteDBLog.Error(name + "æ¥è¦", $"è´§ä½ç¼å·ï¼{Stationinfo.stationCode}ï¼é误信æ¯ï¼{Stationinfo.remark}", "PCS"); |
| | | } |
| | | //if (list.Count > 0 && MaterialSignal != 1) |
| | | //{ |
| | | // client.WriteByOrder("W_Enabl_Load", false, name);//ä¿¡å·ä¸ºfalseæ¡æ¶åæ¢è¿å
¥ |
| | | // Pipeline_client.WriteByOrder("W_AlarmSignal", (Int16)2, name);//æ¥è¦ |
| | | // Stationinfo.location_state = LocationStateEnum.Abnormal.ToString(); |
| | | // Stationinfo.remark = "车轮æ°éä¸å
çµä¸å¹é
"; |
| | | // stationinfoRepository.Update(Stationinfo, true); |
| | | // WriteDBLog.Error(name + "æ¥è¦", $"è´§ä½ç¼å·ï¼{Stationinfo.stationCode}ï¼é误信æ¯ï¼{Stationinfo.remark}", "PCS"); |
| | | // continue; |
| | | //} |
| | | //else if (list.Count < 1 && MaterialSignal == 1) |
| | | //{ |
| | | // client.WriteByOrder("W_Enabl_Load", false, name);//ä¿¡å·ä¸ºfalseæ¡æ¶åæ¢è¿å
¥ |
| | | // Pipeline_client.WriteByOrder("W_AlarmSignal", (Int16)2, name);//æ¥è¦ |
| | | // Stationinfo.location_state = LocationStateEnum.Abnormal.ToString(); |
| | | // Stationinfo.remark = "车轮æ°éä¸å
çµä¸å¹é
"; |
| | | // stationinfoRepository.Update(Stationinfo, true); |
| | | // WriteDBLog.Error(name + "æ¥è¦", $"è´§ä½ç¼å·ï¼{Stationinfo.stationCode}ï¼é误信æ¯ï¼{Stationinfo.remark}", "PCS"); |
| | | // continue; |
| | | //} |
| | | |
| | | #endregion |
| | | |
| | |
| | | var station = Stations.Where(x => x.enable && x.stationCode != NGStation).OrderBy(x => x.lastUpdateTime).FirstOrDefault(); |
| | | agvtask(stationinfoRepository, station, Work, name == "3åå
䏿åº" ? "TaskType_OutsourceInbound" : "TaskType_Inbound"); |
| | | } |
| | | |
| | | //var stationinfos = Stations.Where(x => x.enable && x.Number != Work.workOrder && x.stationCode != NGStation && x.location_state == LocationStateEnum.Stroge.ToString() && x.quantity > 0).ToList(); |
| | | //foreach (var stationinfo in stationinfos) |
| | | //{ |
| | | // agvtask(stationinfoRepository, stationinfo, Work, name == "3åå
䏿åº" ? "TaskType_OutsourceInbound" : "TaskType_Inbound"); |
| | | //} |
| | | #endregion |
| | | } |
| | | |
| | | } |
| | | #endregion |
| | | |
| | | #region ä¸åæ ¼ |
| | | else if ((Int16)PartStatus == 2) |
| | | { |
| | | dt_stationinfo Stationinfo = null; |
| | | //if (mes_Detail.heatID != null) |
| | | //{ |
| | | // Stationinfo = Stations |
| | | //.Where(x => x.enable |
| | | //&& x.stationCode == NGStation |
| | | //&& x.location_state == LocationStateEnum.Stroge.ToString() |
| | | //&& x.quantity < 5 |
| | | //&& x.stationType == mes_Head.drawingNo |
| | | //&& x.tray_type == ((wheel == null ? wheel1.e : wheel.e) < 1100 ? "SmallTray" : "LargeTray") |
| | | //&& x.Number == mes_Detail.jobID |
| | | //&& x.heatNumber == mes_Detail.heatID).FirstOrDefault(); |
| | | //} |
| | | //else |
| | | //{ |
| | | //var tray_type = "SmallTray"; |
| | | //if ((wheel == null ? wheel1.e : wheel.e) > 1100) tray_type = "LargeTray"; |
| | | Stationinfo = Stations |
| | | .Where(x => x.enable |
| | | && x.stationCode == NGStation |
| | | && x.location_state == LocationStateEnum.Stroge.ToString() |
| | | && x.quantity < 5 |
| | | && x.stationType == Work.drawingNo |
| | | //&& x.tray_type == ((wheel == null ? wheel1.e : wheel.e) < 1100 ? "SmallTray" : "LargeTray") |
| | | /*&& x.Number == mes_Detail.jobID*/).FirstOrDefault(); |
| | | //} |
| | | dt_stationinfo Stationinfo = Stations.Where(x => x.enable |
| | | && x.stationCode == NGStation |
| | | && x.location_state == LocationStateEnum.Stroge.ToString() |
| | | && x.quantity < 5 |
| | | && x.stationType == Work.drawingNo).FirstOrDefault(); |
| | | |
| | | if (Stationinfo == null) |
| | | { |
| | |
| | | } |
| | | |
| | | #region è´§ä½æ°éä¸å
çµä¸å¹é
ï¼æ¥è¦ |
| | | |
| | | //if (list.Count > 0 && MaterialSignal != 1) |
| | | //{ |
| | | // client.WriteByOrder("W_Enabl_Load", false, name);//ä¿¡å·ä¸ºfalseæ¡æ¶åæ¢è¿å
¥ |
| | | // Pipeline_client.WriteByOrder("W_AlarmSignal", (Int16)2, name);//æ¥è¦ |
| | | // Stationinfo.location_state = LocationStateEnum.Abnormal.ToString(); |
| | | // Stationinfo.remark = "车轮æ°éä¸å
çµä¸å¹é
"; |
| | | // stationinfoRepository.Update(Stationinfo, true); |
| | | // WriteDBLog.Error(name + "æ¥è¦", $"è´§ä½ç¼å·ï¼{Stationinfo.stationCode}ï¼é误信æ¯ï¼{Stationinfo.remark}", "PCS"); |
| | | //} |
| | | //else if (list.Count < 1 && MaterialSignal == 1) |
| | | //{ |
| | | // client.WriteByOrder("W_Enabl_Load", false, name);//ä¿¡å·ä¸ºfalseæ¡æ¶åæ¢è¿å
¥ |
| | | // Pipeline_client.WriteByOrder("W_AlarmSignal", (Int16)2, name);//æ¥è¦ |
| | | |
| | | if (list.Count > 0 && MaterialSignal != 1) |
| | | { |
| | | client.WriteByOrder("W_Enabl_Load", false, name);//ä¿¡å·ä¸ºfalseæ¡æ¶åæ¢è¿å
¥ |
| | | Pipeline_client.WriteByOrder("W_AlarmSignal", (Int16)2, name);//æ¥è¦ |
| | | Stationinfo.location_state = LocationStateEnum.Abnormal.ToString(); |
| | | Stationinfo.remark = "车轮æ°éä¸å
çµä¸å¹é
"; |
| | | stationinfoRepository.Update(Stationinfo, true); |
| | | WriteDBLog.Error(name + "æ¥è¦", $"è´§ä½ç¼å·ï¼{Stationinfo.stationCode}ï¼é误信æ¯ï¼{Stationinfo.remark}", "PCS"); |
| | | |
| | | //WriteDBLog.Error(name+"ç³è¯·ä¸æ",$"{Stationinfo.stationCode}çè´§ä½","PCS"); |
| | | } |
| | | else if (list.Count < 1 && MaterialSignal == 1) |
| | | { |
| | | client.WriteByOrder("W_Enabl_Load", false, name);//ä¿¡å·ä¸ºfalseæ¡æ¶åæ¢è¿å
¥ |
| | | Pipeline_client.WriteByOrder("W_AlarmSignal", (Int16)2, name);//æ¥è¦ |
| | | Stationinfo.location_state = LocationStateEnum.Abnormal.ToString(); |
| | | Stationinfo.remark = "车轮æ°éä¸å
çµä¸å¹é
"; |
| | | stationinfoRepository.Update(Stationinfo, true); |
| | | WriteDBLog.Error(name + "æ¥è¦", $"è´§ä½ç¼å·ï¼{Stationinfo.stationCode}ï¼é误信æ¯ï¼{Stationinfo.remark}", "PCS"); |
| | | } |
| | | // Stationinfo.location_state = LocationStateEnum.Abnormal.ToString(); |
| | | // Stationinfo.remark = "车轮æ°éä¸å
çµä¸å¹é
"; |
| | | // stationinfoRepository.Update(Stationinfo, true); |
| | | // WriteDBLog.Error(name + "æ¥è¦", $"è´§ä½ç¼å·ï¼{Stationinfo.stationCode}ï¼é误信æ¯ï¼{Stationinfo.remark}", "PCS"); |
| | | //} |
| | | #endregion |
| | | |
| | | //ç¼åæ¶ä¸è½¦è½®æ°éä¸SNå·æ°éä¸ä¸è´ |
| | |
| | | Stationinfo.remark = "车轮æ°éä¸SNå·æ°éä¸ä¸è´"; |
| | | stationinfoRepository.Update(Stationinfo, true); |
| | | continue; |
| | | //åå
¥æ¡æ¶æ¥è¦ä¿¡å· |
| | | //throw new Exception("䏿ä½è½¦è½®æ°éä¸SNå·æ°éä¸ä¸è´ï¼ä¸æä½ç¼å·ï¼" + Stationinfo.stationCode); |
| | | } |
| | | var area = Convert.ToInt16(Stationinfo.stationCode.Substring(Stationinfo.stationCode.Length - 1, 1)); |
| | | client.WriteByOrder("W_AreaNr", (Int16)area, name);//åºåè´§ä½å· |
| | |
| | | } |
| | | } |
| | | } |
| | | #region |
| | | //var Stationinfo = Stations |
| | | // .Where(x => x.enable |
| | | // && x.location_state == LocationStateEnum.Stroge.ToString() |
| | | // && x.quantity < 5 |
| | | // && x.stationType == PipelineJob.QueryMateriel(Wheel_Type) |
| | | // && x.Number == mes_Detail.jobID |
| | | // && x.heatNumber == mes_Detail.heatID).FirstOrDefault(); |
| | | //if (Stationinfo == null) |
| | | // Stationinfo = Stations.Where(x => x.enable && x.location_state == LocationStateEnum.Stroge.ToString() && x.quantity == 0).FirstOrDefault(); |
| | | //if (Stationinfo != null) |
| | | //{ |
| | | |
| | | //} |
| | | |
| | | //List<string> StationCodes = new List<string>() { "X01001001", "X01001002", "X01001003" }; |
| | | //if (name == "2åå
䏿åº") |
| | | // StationCodes = new List<string>() { "X02001001", "X02001002", "X02001003" }; |
| | | //if (name == "3åå
䏿åº") |
| | | // StationCodes = new List<string>() { "X03001001", "X03001002" }; |
| | | |
| | | #endregion |
| | | |
| | | #region |
| | | //for (int i = 0; i < StationCodes.Count - 1; i++) |
| | | //{ |
| | | // var PartStatus = (Int32)DBExtension.Read(details.Where(x => x.plcdetail_name == "R_PartStatus").First(), client);//1:ok;2:nok |
| | | // string NG = StationCodes[StationCodes.Count - 1];//NGè´§ä½ |
| | | // var station = stationinfoRepository.FindFirst(x => x.stationCode == StationCodes[i] && x.enable && x.location_state == LocationStateEnum.Stroge.ToString() && x.quantity < 5); |
| | | // if (station == null) continue; |
| | | // var Pipelinedetails = plcRepository.Find(x => x.plcdetail_iotype == Pipelineplc.plcinfo_iotyep && x.plcdetail_number == StationCodes[i]).ToList(); |
| | | // var PalletSignal = (Int16)DBExtension.Read(Pipelinedetails.Where(x => x.plcdetail_name == "R_PalletSignal").First(), client);//读åæçä¿¡å·:1:æ,2æ |
| | | // if (PalletSignal == 1) |
| | | // { |
| | | // if (PartStatus == 1 && NG != station.stationCode) |
| | | // { |
| | | // client.WriteByOrder("W_AreaNr", (Int16)i + 1, name);//åºåè´§ä½å· |
| | | // client.WriteByOrder("W_IndexNr", (Int16)station.quantity + 1, name);//æçä¸ç第å 个车轮 |
| | | // client.WriteByOrder("W_Storage_Type", (Int16)1, name);//æçç±»å1-横æ¾;2-ç«æ¾(ææ¶åªææ¨ªæ¾æç) |
| | | // client.WriteByOrder("W_Enabl_Load", true, name);//æ¯å¦å
许 |
| | | // return; |
| | | // } |
| | | // else if (PartStatus == 2 && NG == station.stationCode) |
| | | // { |
| | | // client.WriteByOrder("W_AreaNr", (Int16)i + 1, name);//åºåè´§ä½å· |
| | | // client.WriteByOrder("W_IndexNr", (Int16)station.quantity + 1, name);//æçä¸ç第å 个车轮 |
| | | // client.WriteByOrder("W_Storage_Type", (Int16)1, name);//æçç±»å1-横æ¾;2-ç«æ¾(ææ¶åªææ¨ªæ¾æç) |
| | | // client.WriteByOrder("W_Enabl_Load", true, name);//æ¯å¦å
许 |
| | | // return; |
| | | // } |
| | | // } |
| | | //} |
| | | #endregion |
| | | } |
| | | catch (Exception ex) |
| | | { |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using WIDESEA_Comm.LogInfo; |
| | | using WIDESEA_Comm; |
| | | using WIDESEA_Core.EFDbContext; |
| | | using WIDESEA_WCS.IRepositories; |
| | | using WIDESEA_WCS.Repositories; |
| | | using WIDESEA_WCS.WCSClient; |
| | | using WIDESEA_WMS.IRepositories; |
| | | using WIDESEA_WMS.Repositories; |
| | | using HslCommunication; |
| | | using WIDESEA_Entity.DomainModels; |
| | | |
| | | namespace WIDESEA_WCS |
| | | { |
| | | public class Pipeline |
| | | { |
| | | /// <summary> |
| | | /// ä¸æåº |
| | | /// </summary> |
| | | /// <param name="client"></param> |
| | | /// <param name="number"></param> |
| | | public void Loadinglevel(PLCClient client, string number = "䏿åº") |
| | | { |
| | | try |
| | | { |
| | | VOLContext Context = new VOLContext(); |
| | | Idt_plcinfoheadRepository repository = new dt_plcinfoheadRepository(Context); |
| | | Idt_plcinfodetailRepository plcRepository = new dt_plcinfodetailRepository(Context); |
| | | Idt_geometry_dataRepository dataRepository = new dt_geometry_dataRepository(Context); |
| | | Idt_stationinfoRepository stationinfoRepository = new dt_stationinfoRepository(Context); |
| | | var plc = repository.FindFirst(x => x.plcinfo_name == client.PLCName); |
| | | var Gantry_client = PLCClient.Clients.FirstOrDefault(t => t.PLCName == "æ¡æ¶"); |
| | | if (Gantry_client == null) throw new Exception("æ¡æ¶è°åº¦æå¡æªå¼å¯ï¼"); |
| | | if (!Gantry_client.IsConnected) throw new Exception("䏿¡æ¶è¿æ¥è¶
æ¶ï¼"); |
| | | var Gantryplc = repository.FindFirst(x => x.plcinfo_name == Gantry_client.PLCName); |
| | | |
| | | |
| | | ///æ¥æ¾ä¸æåºçè´§ä½ |
| | | 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) |
| | | { |
| | | |
| | | var SNS = Station.bindSN.Split(","); |
| | | |
| | | 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æ |
| | | #region 䏿宿 |
| | | var Gantrydetails = plcRepository.Find(x => x.plcdetail_iotype == Gantryplc.plcinfo_iotyep && x.plcdetail_number == number).ToList(); |
| | | var Gantry_Out_of_Area = (bool)DBExtension.Read(Gantrydetails.Where(x => x.plcdetail_name == "R_Gantry_Out_of_Area").First(), Gantry_client);//æ¡æ¶æ¯å¦å¨åºåå
|
| | | |
| | | var QueryDate = (bool)DBExtension.Read(Gantrydetails.Where(x => x.plcdetail_name == "R_QueryDate").First(), Gantry_client);//ä¿¡æ¯æ¥è¯¢ |
| | | if (QueryDate) |
| | | { |
| | | 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); |
| | | WriteDBLog.Error("䏿åºä¿¡æ¯æ¥è¯¢", $"åå
¥æ¡æ¶ä¿¡æ¯ï¼\nW_RequestUnloadï¼false\n\n{Station.stationCode}æªæ¥è¯¢å°SNå·ï¼{SNS[SNS.Length - 1]}ç订å", "PCS"); |
| | | return; |
| | | } |
| | | } |
| | | var finished = (bool)DBExtension.Read(Gantrydetails.Where(x => x.plcdetail_name == "R_Unlod_finished").First(), Gantry_client);//夹å宿 |
| | | var updatefinished = (bool)DBExtension.Read(Gantrydetails.Where(x => x.plcdetail_name == "W_Storage_update").First(), Gantry_client);//è´§ä½ç¶ææ´æ° |
| | | if (!finished && updatefinished) |
| | | Gantry_client.WriteByOrder("W_Storage_update", false, number);//è´§ä½ç¶ææ´æ° |
| | | if (finished && !updatefinished) |
| | | { |
| | | Gantry_client.WriteByOrder("W_RequestUnload", false, number);//ä¿¡å·ä¸ºfalseæ¡æ¶åæ¢è¿å
¥ |
| | | Updatemes(SNS[SNS.Length - 1]); |
| | | Station.quantity = Station.quantity - 1; |
| | | Station.bindSN = OperStr(SNS); |
| | | if (Station.quantity <= 0) |
| | | { |
| | | Station.stationType = string.Empty; |
| | | Station.Number = string.Empty; |
| | | Station.heatNumber = string.Empty; |
| | | Station.tray_status = "EmptyTray"; |
| | | } |
| | | var count = stationinfoRepository.Update(Station, true); |
| | | if (count < 1) |
| | | { |
| | | WriteDBLog.Error("åæå®æ", $"䏿ä½ä¿¡æ¯æ´æ°å¤±è´¥ï¼ä¸æä½ç¼å·ï¼{Station.stationCode}", "PCS"); |
| | | 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 |
| | | |
| | | 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"); |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region ç³è¯·ä¸æ |
| | | //var SNS = Station.bindSN.Split(","); |
| | | if (Gantry_client.ReadByOrder<bool>("W_RequestUnload", number)) return; |
| | | |
| | | Station = stationinfoRepository.Find(x => x.stationCode == Station.stationCode).FirstOrDefault(); |
| | | if (Station.quantity < 1) return; |
| | | List<string> list = new List<string>(); |
| | | SNS = Station.bindSN.Split(","); |
| | | foreach (var SN in SNS) |
| | | { |
| | | if (!string.IsNullOrEmpty(SN)) |
| | | list.Add(SN); |
| | | } |
| | | //ç¼åæ¶ä¸è½¦è½®æ°éä¸SNå·æ°éä¸ä¸è´ |
| | | if (list.Count != Station.quantity) |
| | | { |
| | | Station.location_state = LocationStateEnum.Abnormal.ToString(); |
| | | Station.remark = "车轮æ°éä¸SNå·æ°éä¸ä¸è´"; |
| | | stationinfoRepository.Update(Station, true); |
| | | Gantry_client.WriteByOrder("W_RequestUnload", false, number);//ä¿¡å·ä¸ºfalseæ¡æ¶åæ¢è¿å
¥ |
| | | #region æ¥å¿è®°å½ |
| | | WriteDBLog.Error("䏿åº", $"åå
¥æ¡æ¶ä¿¡æ¯ï¼\nW_RequestUnloadï¼false\n\n{Station.stationCode}车轮æ°éä¸SNå·æ°éä¸ä¸è´", "PCS"); |
| | | #endregion |
| | | return; |
| | | } |
| | | //var details = plcRepository.Find(x => x.plcdetail_iotype == plc.plcinfo_iotyep && x.plcdetail_number == Station.stationCode).ToList(); |
| | | 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æ |
| | | |
| | | var AreaNr = Gantry_client.ReadByOrder<Int16>("W_AreaNr", number);//读åè´§ä½å·ä¿¡æ¯ |
| | | if (PalletSignal == 1 && MaterialSignal == 1) |
| | | { |
| | | 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 |
| | | { |
| | | Gantry_client.WriteByOrder("W_RequestUnload", false, number); |
| | | } |
| | | #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"); |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | } |
| | | else |
| | | Gantry_client.WriteByOrder("W_RequestUnload", false, number);//ä¿¡å·ä¸ºfalseæ¡æ¶åæ¢è¿å
¥ |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | WriteDBLog.Error("䏿åº", $"é误信æ¯ï¼{ex.Message}", "PCS"); |
| | | } |
| | | } |
| | | |
| | | private string OperStr(string[] strArrty) |
| | | { |
| | | string[] newstr = strArrty.RemoveLast(1); |
| | | string Newsn = string.Join(",", newstr); |
| | | |
| | | return Newsn; |
| | | } |
| | | public static dt_geometry_data QueryMateriel(string type) |
| | | { |
| | | VOLContext Context = new VOLContext(); |
| | | Idt_geometry_dataRepository dataRepository = new dt_geometry_dataRepository(Context); |
| | | var materielinfo = dataRepository.Find(x => x.Description == type).OrderBy(x => x.TypeId).FirstOrDefault(); |
| | | return materielinfo; |
| | | } |
| | | public static dt_geometry_data_detectionline QueryMateriel1(string type) |
| | | { |
| | | VOLContext Context = new VOLContext(); |
| | | Idt_geometry_data_detectionlineRepository detectionlineRepository = new dt_geometry_data_detectionlineRepository(Context); |
| | | var materielinfo1 = detectionlineRepository.Find(x => x.Description == type).OrderBy(x => x.TypeId).FirstOrDefault(); |
| | | return materielinfo1; |
| | | } |
| | | |
| | | public static string area_code(string area_name) |
| | | { |
| | | VOLContext Context = new VOLContext(); |
| | | Idt_areainfoRepository areainfoRepository = new dt_areainfoRepository(Context); |
| | | var areainfo = areainfoRepository.Find(x => x.area_name == area_name).FirstOrDefault(); |
| | | return areainfo.area_code.ToString(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// æ´æ¹å·¥åç¶æ |
| | | /// </summary> |
| | | /// <param name="SN"></param> |
| | | public static void Updatemes(string SN) |
| | | { |
| | | 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_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 = "ä¸çº¿"; |
| | | mes_Detail.FinishTime = DateTime.Now; |
| | | //freeDB.DataBase.Update<dt_mes_detail>().SetSource(mes_Detail).UpdateColumns(x => new { x.Status, x.FinishTime }).ExecuteAffrows(); |
| | | mes_DetailRepository.Update(mes_Detail, true); |
| | | //var mes_Head = freeDB.Select<dt_mes_head>().Where(x => x.jobID == mes_Detail.jobID).First(); |
| | | var mes_Head = mes_HeadRepository.Find(x => x.jobID == mes_Detail.jobID).FirstOrDefault(); |
| | | if (mes_Head != null) |
| | | { |
| | | mes_Head.finishNum = mes_Head.finishNum + 1; |
| | | //freeDB.DataBase.Update<dt_mes_head>().SetSource(mes_Head).UpdateColumns(x => new { x.finishNum }).ExecuteAffrows(); |
| | | mes_HeadRepository.Update(mes_Head, true); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | private void DoAction(IJobExecutionContext context) |
| | | { |
| | | StationTask.CreateTask(); |
| | | OutboundTask.CreateOutboundTask();//ä¼åååºåºé»è¾ |
| | | ReplaceTray.ReplaceTrayTask(); |
| | | RestockHCJ.HCJGetBarcode(); |
| | | EmptyTrayTask.CreateEmptyTrayTask(); |
| | | AutoUpdateWork.FinishMesWork(); |
| | | EmptyTray.EmptyTrayIn();//空æå çå
¥åº |
| | | StationTask.CreateTask();//å
¥åº |
| | | OutboundTask.CreateOutboundTask();//åºåº |
| | | ReplaceTray.ReplaceTrayTask();//æ´æ¢æç |
| | | RestockHCJ.HCJGetBarcode();//æ´æ°éå |
| | | EmptyTrayTask.CreateEmptyTrayTask();//å建补空æ |
| | | AutoUpdateWork.FinishMesWork();//å¤çå·¥å |
| | | } |
| | | } |
| | | } |
| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Net; |
| | | using System.Reflection; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | |
| | | VOLContext Context = new VOLContext(); |
| | | Idt_plcinfoheadRepository repository = new dt_plcinfoheadRepository(Context); |
| | | Idt_plcinfodetailRepository plcRepository = new dt_plcinfodetailRepository(Context); |
| | | Idt_geometry_dataRepository dataRepository = new dt_geometry_dataRepository(Context); |
| | | Idt_stationinfoRepository stationinfoRepository = new dt_stationinfoRepository(Context); |
| | | var plc = repository.FindFirst(x => x.plcinfo_name == client.PLCName); |
| | | var Gantry_client = PLCClient.Clients.FirstOrDefault(t => t.PLCName == "æ¡æ¶"); |
| | |
| | | var Gantryplc = repository.FindFirst(x => x.plcinfo_name == Gantry_client.PLCName); |
| | | |
| | | |
| | | ///æ¥æ¾ä¸æåºçè´§ä½ |
| | | var Stations = stationinfoRepository.Find(x => x.area == area_code(number)).OrderBy(x => x.lastUpdateTime);//æ ¹æ®æ¶é´å
åæåº |
| | | #region 䏿宿 |
| | | |
| | | var Station = Stations?.Where(x => x.enable && x.location_state == LocationStateEnum.Stroge.ToString() && x.quantity > 0).OrderBy(x => x.quantity).FirstOrDefault(); |
| | | if (Station != null) |
| | | var AreaNr = Gantry_client.ReadByOrder<Int16>("W_AreaNr", number);//读åè´§ä½å·ä¿¡æ¯ |
| | | if (AreaNr != 0) |
| | | { |
| | | var SNS = Station.bindSN.Split(","); |
| | | List<string> list = new List<string>(); |
| | | foreach (var SN in SNS) |
| | | var station = stationinfoRepository.Find(x => x.area == area_code(number) && x.stationCode.Substring(x.stationCode.Length - 1, 1) == AreaNr.ToString()).FirstOrDefault(); |
| | | if (station != null) |
| | | { |
| | | if (!string.IsNullOrEmpty(SN)) |
| | | list.Add(SN); |
| | | } |
| | | //ç¼åæ¶ä¸è½¦è½®æ°éä¸SNå·æ°éä¸ä¸è´ |
| | | if (list.Count != Station.quantity) |
| | | { |
| | | Station.location_state = LocationStateEnum.Abnormal.ToString(); |
| | | Station.remark = "车轮æ°éä¸SNå·æ°éä¸ä¸è´"; |
| | | stationinfoRepository.Update(Station, true); |
| | | Gantry_client.WriteByOrder("W_RequestUnload", false, number);//ä¿¡å·ä¸ºfalseæ¡æ¶åæ¢è¿å
¥ |
| | | #region æ¥å¿è®°å½ |
| | | WriteDBLog.Error("䏿åº", $"åå
¥æ¡æ¶ä¿¡æ¯ï¼\nW_RequestUnloadï¼false\n\n{Station.stationCode}车轮æ°éä¸SNå·æ°éä¸ä¸è´", "PCS"); |
| | | #endregion |
| | | return; |
| | | } |
| | | 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 bindSNS = station.bindSN.Split(","); |
| | | var Gantrydetails = plcRepository.Find(x => x.plcdetail_iotype == Gantryplc.plcinfo_iotyep && x.plcdetail_number == number).ToList(); |
| | | |
| | | var AreaNr = Gantry_client.ReadByOrder<Int16>("W_AreaNr", number);//读åè´§ä½å·ä¿¡æ¯ |
| | | if (PalletSignal == 1 && MaterialSignal == 1) |
| | | #region ä¿¡æ¯æ¥è¯¢ç¡®è®¤ |
| | | var QueryDate = (bool)DBExtension.Read(Gantrydetails.Where(x => x.plcdetail_name == "R_QueryDate").First(), Gantry_client);//ä¿¡æ¯æ¥è¯¢ |
| | | if (QueryDate) |
| | | { |
| | | 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å·ï¼{bindSNS[bindSNS.Length - 1]}ç订å"; |
| | | stationinfoRepository.Update(station, true); |
| | | WriteDBLog.Error("䏿åºä¿¡æ¯æ¥è¯¢", $"åå
¥æ¡æ¶ä¿¡æ¯ï¼\nW_RequestUnloadï¼false\n\n{station.stationCode}æªæ¥è¯¢å°SNå·ï¼{bindSNS[bindSNS.Length - 1]}ç订å", "PCS"); |
| | | return; |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region è´§ä½ç¶ææ´æ°å¤ä½ |
| | | var finished = (bool)DBExtension.Read(Gantrydetails.Where(x => x.plcdetail_name == "R_Unlod_finished").First(), Gantry_client);//夹å宿 |
| | | var updatefinished = (bool)DBExtension.Read(Gantrydetails.Where(x => x.plcdetail_name == "W_Storage_update").First(), Gantry_client);//è´§ä½ç¶ææ´æ° |
| | | if (!finished && updatefinished) |
| | | { |
| | | Gantry_client.WriteByOrder("W_Storage_update", false, number);//è´§ä½ç¶ææ´æ° |
| | | WriteLog.Write_Log(number + "䏿宿", number + "è´§ä½ç¶ææ´æ°ä¿¡å·å¤ä½", "æåï¼", |
| | | $"è¯»åæ¡æ¶ä¿¡æ¯ï¼\nä¸æå®æä¿¡å·ï¼{finished}\n\nåå
¥æ¡æ¶ä¿¡æ¯ï¼\nè´§ä½ç¶ææ´æ°ä¿¡å·ï¼{false}"); |
| | | } |
| | | #endregion |
| | | |
| | | if (finished && !updatefinished) |
| | | { |
| | | |
| | | #region 夿åºåå·æ¯å¦ä¸è´ |
| | | var area = Gantry_client.ReadByOrder<Int16>("place_prog", number);//æ¾æå®æçåºåå· |
| | | |
| | | WriteLog.Write_Log(number + "åæå®æåºé", bindSNS[bindSNS.Length - 1], "夿åºåå·æ¯å¦ä¸è´", $"PCSåºåå·ï¼{AreaNr}ï¼\næ¡æ¶åºåå·ï¼{area}\né误信æ¯ï¼PCSåºåå·ä¸æ¡æ¶åºåå·ä¸ä¸è´ï¼"); |
| | | //if (AreaNr != area) |
| | | //{ |
| | | // client.WriteByOrder("W_AlarmSignal", (Int16)2, number);//æ¥è¦ |
| | | // //WriteDBLog.Error(name + "æ¥è¦", $"PCSåºåå·ï¼{AreaNr}ï¼æ¡æ¶åºåå·ï¼{area}é误信æ¯ï¼PCSåºåå·ä¸æ¡æ¶åºåå·ä¸ä¸è´ï¼", "PCS"); |
| | | // WriteLog.Write_Log(number + "åæå®æåºé", bindSNS[bindSNS.Length - 1], "夿åºåå·æ¯å¦ä¸è´", $"PCSåºåå·ï¼{AreaNr}ï¼\næ¡æ¶åºåå·ï¼{area}\né误信æ¯ï¼PCSåºåå·ä¸æ¡æ¶åºåå·ä¸ä¸è´ï¼"); |
| | | // return; |
| | | //} |
| | | #endregion |
| | | |
| | | #region å¤æè½¦è½®æ°éæ¯å¦ä¸è´ |
| | | 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åºåå·ä¸æ¡æ¶åºåå·ä¸ä¸è´ï¼"); |
| | | //if (quantity != station.quantity) |
| | | //{ |
| | | // client.WriteByOrder("W_AlarmSignal", (Int16)2, number);//æ¥è¦ |
| | | // WriteLog.Write_Log(number + "åæå®æåºé", bindSNS[bindSNS.Length - 1], "å¤æè½¦è½®æ°éæ¯å¦ä¸è´", $"åºåå·ï¼{AreaNr}ï¼\næ¡æ¶è½¦è½®æ°ï¼{quantity}\nPCS车轮æ°ï¼{station.quantity}\né误信æ¯ï¼PCSåºåå·ä¸æ¡æ¶åºåå·ä¸ä¸è´ï¼"); |
| | | // return; |
| | | //} |
| | | #endregion |
| | | |
| | | Updatemes(bindSNS[bindSNS.Length - 1]); |
| | | station.quantity = station.quantity - 1; |
| | | station.bindSN = OperStr(bindSNS); |
| | | if (station.quantity <= 0) |
| | | { |
| | | station.stationType = string.Empty; |
| | | station.Number = string.Empty; |
| | | station.heatNumber = string.Empty; |
| | | station.tray_status = "EmptyTray"; |
| | | } |
| | | var count = stationinfoRepository.Update(station, true); |
| | | if (count < 1) |
| | | { |
| | | WriteDBLog.Error("åæå®æ", $"䏿ä½ä¿¡æ¯æ´æ°å¤±è´¥ï¼ä¸æä½ç¼å·ï¼{station.stationCode}", "PCS"); |
| | | return; |
| | | } |
| | | |
| | | Gantry_client.WriteByOrder("W_Storage_update", true, number);//è´§ä½ç¶ææ´æ° |
| | | Gantry_client.WriteByOrder("W_RequestUnload", false, number);//ä¿¡å·ä¸ºfalseæ¡æ¶åæ¢è¿å
¥ |
| | | |
| | | #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 |
| | | |
| | | #region æ¥å¿è®°å½ |
| | | WriteDBLog.Success("åæå®æ", $"åå
¥æ¡æ¶ä¿¡æ¯ï¼\nè´§ä½ç¶ææ´æ°ï¼{true}\nW_RequestUnloadï¼{false}", "PCS"); |
| | | #endregion |
| | | } |
| | | } |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ç³è¯·ä¸æ |
| | | |
| | | if (!Gantry_client.ReadByOrder<bool>("W_RequestUnload", number)) |
| | | { |
| | | var Station = stationinfoRepository.Find(x => x.area == area_code(number) && x.enable && x.location_state == LocationStateEnum.Stroge.ToString() && x.quantity > 0).OrderBy(x => x.lastUpdateTime).FirstOrDefault(); |
| | | if (Station != null) |
| | | { |
| | | if (AreaNr == 0) |
| | | var SNS = Station.bindSN.Split(","); |
| | | List<string> list = new List<string>(); |
| | | foreach (var SN in SNS) |
| | | { |
| | | if (!string.IsNullOrEmpty(SN)) |
| | | list.Add(SN); |
| | | } |
| | | //ç¼åæ¶ä¸è½¦è½®æ°éä¸SNå·æ°éä¸ä¸è´ |
| | | if (list.Count != Station.quantity) |
| | | { |
| | | Station.location_state = LocationStateEnum.Abnormal.ToString(); |
| | | Station.remark = "车轮æ°éä¸SNå·æ°éä¸ä¸è´"; |
| | | stationinfoRepository.Update(Station, true); |
| | | Gantry_client.WriteByOrder("W_RequestUnload", false, number);//ä¿¡å·ä¸ºfalseæ¡æ¶åæ¢è¿å
¥ |
| | | #region æ¥å¿è®°å½ |
| | | WriteDBLog.Error("䏿åº", $"åå
¥æ¡æ¶ä¿¡æ¯ï¼\nW_RequestUnloadï¼false\n\n{Station.stationCode}车轮æ°éä¸SNå·æ°éä¸ä¸è´", "PCS"); |
| | | #endregion |
| | | return; |
| | | } |
| | | |
| | | 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æ |
| | | |
| | | 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 area = Convert.ToInt16(Station.stationCode.Substring(Station.stationCode.Length - 1, 1)); |
| | |
| | | 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åºåè´§ä½å·ï¼{area}\næçä¸ç第å 个车轮ï¼{SNS.Length}\næçç±»åï¼{1}\n车轮类åï¼{(QueryMateriel(Station.stationType) == null ? QueryMateriel1(Station.stationType).TypeId : QueryMateriel(Station.stationType).TypeId)}" + |
| | | $"\n车轮SNå·ï¼{SNS[SNS.Length - 1]}\nW_RequestUnloadï¼true", "PCS"); |
| | | #endregion |
| | | } |
| | | } |
| | | else |
| | | { |
| | | Gantry_client.WriteByOrder("W_RequestUnload", false, number); |
| | | } |
| | | |
| | | var Gantrydetails = plcRepository.Find(x => x.plcdetail_iotype == Gantryplc.plcinfo_iotyep && x.plcdetail_number == number).ToList(); |
| | | var Gantry_Out_of_Area = (bool)DBExtension.Read(Gantrydetails.Where(x => x.plcdetail_name == "R_Gantry_Out_of_Area").First(), Gantry_client);//æ¡æ¶æ¯å¦å¨åºåå
|
| | | |
| | | var QueryDate = (bool)DBExtension.Read(Gantrydetails.Where(x => x.plcdetail_name == "R_QueryDate").First(), Gantry_client);//ä¿¡æ¯æ¥è¯¢ |
| | | if (QueryDate) |
| | | { |
| | | var Date_Vaild = (bool)DBExtension.Read(Gantrydetails.Where(x => x.plcdetail_name == "R_Date_Vaild").First(), Gantry_client);//ä¿¡æ¯ç¡®è®¤ |
| | | if (!Date_Vaild)//ä¿¡æ¯æè¯¯ï¼è®°å½æ¥å¿ |
| | | else |
| | | { |
| | | 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); |
| | | WriteDBLog.Error("䏿åºä¿¡æ¯æ¥è¯¢", $"åå
¥æ¡æ¶ä¿¡æ¯ï¼\nW_RequestUnloadï¼false\n\n{Station.stationCode}æªæ¥è¯¢å°SNå·ï¼{SNS[SNS.Length - 1]}ç订å", "PCS"); |
| | | return; |
| | | } |
| | | } |
| | | var finished = (bool)DBExtension.Read(Gantrydetails.Where(x => x.plcdetail_name == "R_Unlod_finished").First(), Gantry_client);//夹å宿 |
| | | var updatefinished = (bool)DBExtension.Read(Gantrydetails.Where(x => x.plcdetail_name == "W_Storage_update").First(), Gantry_client);//è´§ä½ç¶ææ´æ° |
| | | if (!finished && updatefinished) |
| | | Gantry_client.WriteByOrder("W_Storage_update", false, number);//è´§ä½ç¶ææ´æ° |
| | | if (finished && !updatefinished) |
| | | { |
| | | Gantry_client.WriteByOrder("W_RequestUnload", false, number);//ä¿¡å·ä¸ºfalseæ¡æ¶åæ¢è¿å
¥ |
| | | Updatemes(SNS[SNS.Length - 1]); |
| | | Station.quantity = Station.quantity - 1; |
| | | Station.bindSN = OperStr(SNS); |
| | | if (Station.quantity <= 0) |
| | | { |
| | | Station.stationType = string.Empty; |
| | | Station.Number = string.Empty; |
| | | Station.heatNumber = string.Empty; |
| | | Station.tray_status = "EmptyTray"; |
| | | } |
| | | var count = stationinfoRepository.Update(Station, true); |
| | | if (count < 1) |
| | | { |
| | | WriteDBLog.Error("åæå®æ", $"䏿ä½ä¿¡æ¯æ´æ°å¤±è´¥ï¼ä¸æä½ç¼å·ï¼{Station.stationCode}", "PCS"); |
| | | return; |
| | | Gantry_client.WriteByOrder("W_RequestUnload", false, number); |
| | | } |
| | | |
| | | #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);//车轮类å |
| | | #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"); |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | Gantry_client.WriteByOrder("W_Storage_update", true, number);//è´§ä½ç¶ææ´æ° |
| | | #region æ¥å¿è®°å½ |
| | | WriteDBLog.Success("åæå®æ", $"åå
¥æ¡æ¶ä¿¡æ¯ï¼\nè´§ä½ç¶ææ´æ°ï¼{true}\nW_RequestUnloadï¼{false}", "PCS"); |
| | | #endregion |
| | | |
| | | 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æ¡æ¶åæ¢è¿å
¥ |
| | | |
| | | #endregion |
| | | |
| | | |
| | | #region MyRegion |
| | | |
| | | /////æ¥æ¾ä¸æåºçè´§ä½ |
| | | //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) |
| | | //{ |
| | | // var SNS = Station.bindSN.Split(","); |
| | | // List<string> list = new List<string>(); |
| | | // foreach (var SN in SNS) |
| | | // { |
| | | // if (!string.IsNullOrEmpty(SN)) |
| | | // list.Add(SN); |
| | | // } |
| | | // //ç¼åæ¶ä¸è½¦è½®æ°éä¸SNå·æ°éä¸ä¸è´ |
| | | // if (list.Count != Station.quantity) |
| | | // { |
| | | // Station.location_state = LocationStateEnum.Abnormal.ToString(); |
| | | // Station.remark = "车轮æ°éä¸SNå·æ°éä¸ä¸è´"; |
| | | // stationinfoRepository.Update(Station, true); |
| | | // Gantry_client.WriteByOrder("W_RequestUnload", false, number);//ä¿¡å·ä¸ºfalseæ¡æ¶åæ¢è¿å
¥ |
| | | // #region æ¥å¿è®°å½ |
| | | // WriteDBLog.Error("䏿åº", $"åå
¥æ¡æ¶ä¿¡æ¯ï¼\nW_RequestUnloadï¼false\n\n{Station.stationCode}车轮æ°éä¸SNå·æ°éä¸ä¸è´", "PCS"); |
| | | // #endregion |
| | | // return; |
| | | // } |
| | | // 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) |
| | | // { |
| | | // 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 |
| | | // { |
| | | // Gantry_client.WriteByOrder("W_RequestUnload", false, number); |
| | | // } |
| | | |
| | | // var Gantrydetails = plcRepository.Find(x => x.plcdetail_iotype == Gantryplc.plcinfo_iotyep && x.plcdetail_number == number).ToList(); |
| | | // var Gantry_Out_of_Area = (bool)DBExtension.Read(Gantrydetails.Where(x => x.plcdetail_name == "R_Gantry_Out_of_Area").First(), Gantry_client);//æ¡æ¶æ¯å¦å¨åºåå
|
| | | |
| | | // var QueryDate = (bool)DBExtension.Read(Gantrydetails.Where(x => x.plcdetail_name == "R_QueryDate").First(), Gantry_client);//ä¿¡æ¯æ¥è¯¢ |
| | | // if (QueryDate) |
| | | // { |
| | | // 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); |
| | | // WriteDBLog.Error("䏿åºä¿¡æ¯æ¥è¯¢", $"åå
¥æ¡æ¶ä¿¡æ¯ï¼\nW_RequestUnloadï¼false\n\n{Station.stationCode}æªæ¥è¯¢å°SNå·ï¼{SNS[SNS.Length - 1]}ç订å", "PCS"); |
| | | // return; |
| | | // } |
| | | // } |
| | | // var finished = (bool)DBExtension.Read(Gantrydetails.Where(x => x.plcdetail_name == "R_Unlod_finished").First(), Gantry_client);//夹å宿 |
| | | // var updatefinished = (bool)DBExtension.Read(Gantrydetails.Where(x => x.plcdetail_name == "W_Storage_update").First(), Gantry_client);//è´§ä½ç¶ææ´æ° |
| | | // if (!finished && updatefinished) |
| | | // Gantry_client.WriteByOrder("W_Storage_update", false, number);//è´§ä½ç¶ææ´æ° |
| | | // if (finished && !updatefinished) |
| | | // { |
| | | // Gantry_client.WriteByOrder("W_RequestUnload", false, number);//ä¿¡å·ä¸ºfalseæ¡æ¶åæ¢è¿å
¥ |
| | | // Updatemes(SNS[SNS.Length - 1]); |
| | | // Station.quantity = Station.quantity - 1; |
| | | // Station.bindSN = OperStr(SNS); |
| | | // if (Station.quantity <= 0) |
| | | // { |
| | | // Station.stationType = string.Empty; |
| | | // Station.Number = string.Empty; |
| | | // Station.heatNumber = string.Empty; |
| | | // Station.tray_status = "EmptyTray"; |
| | | // } |
| | | // var count = stationinfoRepository.Update(Station, true); |
| | | // if (count < 1) |
| | | // { |
| | | // WriteDBLog.Error("åæå®æ", $"䏿ä½ä¿¡æ¯æ´æ°å¤±è´¥ï¼ä¸æä½ç¼å·ï¼{Station.stationCode}", "PCS"); |
| | | // 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 |
| | | |
| | | // #region æ¥è¦ |
| | | // 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"); |
| | | // } |
| | | // #endregion |
| | | |
| | | |
| | | // } |
| | | //} |
| | | //else |
| | | // Gantry_client.WriteByOrder("W_RequestUnload", false, number);//ä¿¡å·ä¸ºfalseæ¡æ¶åæ¢è¿å
¥ |
| | | #endregion |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | |
| | | Idt_stationinfoRepository stationinfoRepository = new dt_stationinfoRepository(Context); |
| | | var plc = repository.FindFirst(x => x.plcinfo_name == client.PLCName); |
| | | List<string> stationCodes = new List<string>() { "S01001001", "S01001002", "W01001001", "W01001002", "W01001003" }; |
| | | string remark = ""; |
| | | foreach (var stationCode in stationCodes) |
| | | { |
| | | 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æ |
| | | if (PalletSignal == 1 && MaterialSignal == 2 && (station.stationCode.Contains("S0100100") ? station.tray_status == "EmptyTray" : true)) |
| | | try |
| | | { |
| | | 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).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); |
| | | remark = "æ¥è¯¢ç«å°"; |
| | | var station = stationinfoRepository.Find(x => x.stationCode == stationCode && x.enable).FirstOrDefault(); |
| | | if (station == null) continue; |
| | | remark = "æ¥è¯¢èµ·ç¹æ¯å¦åå¨ä»»å¡"; |
| | | if (agvtaskService.Find(x => x.agv_fromaddress == stationCode /*|| x.agv_toaddress == stationCode*/).Any()) |
| | | continue; |
| | | |
| | | } |
| | | |
| | | #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 = EmptyStations.Where(x => x.location_state == LocationStateEnum.Empty.ToString()).FirstOrDefault(); |
| | | #endregion |
| | | |
| | | if (EmptyStation == null)//æ¥æ¾åºå
空æç |
| | | EmptyStation = GetStation.EmptyPalletStation(area); |
| | | |
| | | |
| | | if (EmptyStation != null) |
| | | remark = "读åå
çµä¿¡å·"; |
| | | 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æ |
| | | if (PalletSignal == 1 && MaterialSignal == 2 && (station.stationCode.Contains("S0100100") ? station.tray_status == "EmptyTray" : true)) |
| | | { |
| | | #region åä¸ä¸ªç©ºæä½åªè½åæ¶çæä¸ä¸ªç©ºæä»»å¡ |
| | | if (agvtaskService.Find(x => x.agv_fromaddress == EmptyStation.stationCode || x.agv_toaddress == EmptyStation.stationCode).Any()) |
| | | return; |
| | | #endregion |
| | | dt_agvtask agvtask = new dt_agvtask() |
| | | 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) |
| | | { |
| | | 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}", "PCS"); |
| | | return; |
| | | 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 空æå ç |
| | | 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 = EmptyStations.Where(x => x.location_state == LocationStateEnum.Empty.ToString() && x.quantity == 0).FirstOrDefault(); |
| | | #endregion |
| | | remark = "æ¥æ¾åºå
空æä½"; |
| | | if (EmptyStation == null)//æ¥æ¾åºå
空æç |
| | | EmptyStation = GetStation.EmptyPalletStation(area); |
| | | |
| | | |
| | | if (EmptyStation != null) |
| | | { |
| | | #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"); |
| | | } |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | WriteDBLog.Error("å建èªå¨å空æä»»å¡", $"{stationCode}ï¼{remark}é误信æ¯ï¼{ex.Message}", "PCS"); |
| | | } |
| | | } |
| | | } |
| | |
| | | if (Station.quantity > 0 && (PalletSignal != 1 || MaterialSignal != 1))//ç³»ç»è´§ä½æè½¦è½®ï¼å
çµæ£æµæ 车轮 |
| | | { |
| | | Station.location_state = LocationStateEnum.Abnormal.ToString(); |
| | | Station.remark = "车轮æ°é大äº0ï¼å
çµæ£æµæ æçææ è½¦è½®"; |
| | | Station.remark = $"车轮æ°é大äº0ï¼æçå
çµä¿¡å·ä¸ºï¼{PalletSignal}ï¼è´§ç©å
çµä¿¡å·ä¸ºï¼{MaterialSignal}"; |
| | | stationinfoRepository.Update(Station, true); |
| | | client.WriteByOrder("W_AlarmSignal", (Int16)2, name);//æ¥è¦ |
| | | WriteDBLog.Error(name + "æ¥è¦", $"è´§ä½ç¼å·ï¼{Station.stationCode}ï¼é误信æ¯ï¼{Station.remark}", "PCS"); |
| | |
| | | if (Station.location_state == LocationStateEnum.Stroge.ToString() && PalletSignal != 1) |
| | | { |
| | | Station.location_state = LocationStateEnum.Abnormal.ToString(); |
| | | Station.remark = "å
çµæ£æµæ æç"; |
| | | Station.remark = $"è´§ä½ç¶æä¸ºæè´§ï¼æçå
çµä¿¡å·ä¸ºï¼{PalletSignal}ï¼è´§ç©å
çµä¿¡å·ä¸ºï¼{MaterialSignal}"; |
| | | stationinfoRepository.Update(Station, true); |
| | | client.WriteByOrder("W_AlarmSignal", (Int16)2, name);//æ¥è¦ |
| | | WriteDBLog.Error(name + "æ¥è¦", $"è´§ä½ç¼å·ï¼{Station.stationCode}ï¼é误信æ¯ï¼{Station.remark}", "PCS"); |
| | |
| | | if (Station.location_state == LocationStateEnum.Empty.ToString() && (PalletSignal == 1 || MaterialSignal == 1))//ç³»ç»è´§ä½ä¸ºç©ºï¼å
çµæ£æµææ |
| | | { |
| | | Station.location_state = LocationStateEnum.Abnormal.ToString(); |
| | | Station.remark = "å
çµæ£æµææ"; |
| | | Station.remark = $"è´§ä½ç¶æä¸ºç©ºè´§ä½ï¼æçå
çµä¿¡å·ä¸ºï¼{PalletSignal}ï¼è´§ç©å
çµä¿¡å·ä¸ºï¼{MaterialSignal}"; |
| | | stationinfoRepository.Update(Station, true); |
| | | client.WriteByOrder("W_AlarmSignal", (Int16)2, name);//æ¥è¦ |
| | | WriteDBLog.Error(name + "æ¥è¦", $"è´§ä½ç¼å·ï¼{Station.stationCode}ï¼é误信æ¯ï¼{Station.remark}", "PCS"); |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using WIDESEA_Comm.LogInfo; |
| | | using WIDESEA_Comm.TaskNo; |
| | | using WIDESEA_Comm; |
| | | using WIDESEA_Core.EFDbContext; |
| | | using WIDESEA_Entity.DomainModels; |
| | | using WIDESEA_WCS.IRepositories; |
| | | using WIDESEA_WCS.Repositories; |
| | | using static System.Collections.Specialized.BitVector32; |
| | | using WIDESEA_WMS.IRepositories; |
| | | using WIDESEA_WMS.Repositories; |
| | | |
| | | namespace WIDESEA_WCS.JobsPart.Common |
| | | { |
| | | public class EmptyTray |
| | | { |
| | | /// <summary> |
| | | /// 空æå çå
¥åº |
| | | /// </summary> |
| | | public static void EmptyTrayIn() |
| | | { |
| | | try |
| | | { |
| | | 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(); |
| | | 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"); |
| | | } |
| | | |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | WriteDBLog.Success("å建å çä½ç©ºæå
¥åºä»»å¡", $"é误信æ¯ï¼{ex.Message}", "PCS"); |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | dt_stationinfo stationinfo = null; |
| | | try |
| | | { |
| | | if (stationinfoRepository.Find(x => x.area == EmptyStation.area && x.line == EmptyStation.line && x.location_state.Contains("Busy")).Any()) return null; |
| | | if (stationinfoRepository.Find(x => x.area == EmptyStation.area && x.line == EmptyStation.line && x.location_state.Contains("Busy")).Any()) return stationinfo; |
| | | |
| | | |
| | | stationinfo = stationinfoRepository.Find(x => x.area == EmptyStation.area && x.line == EmptyStation.line && x.quantity > 0 && x.enable).OrderByDescending(x => x.column).FirstOrDefault(); |
| | |
| | | else |
| | | stationinfo = stationinfoRepository.Find(x => x.area == EmptyStation.area && x.line == EmptyStation.line && x.location_state == LocationStateEnum.Empty.ToString() && x.enable).OrderBy(x => x.column).FirstOrDefault(); |
| | | } |
| | | else |
| | | { |
| | | stationinfo = stationinfoRepository.Find(x => x.area == EmptyStation.area && x.line == EmptyStation.line && x.location_state == LocationStateEnum.Empty.ToString() && x.enable).OrderBy(x => x.column).FirstOrDefault(); |
| | | } |
| | | //if (stationinfo == null) |
| | | // stationinfo = stationinfoRepository.Find(x => x.area == EmptyStation.area && x.line == EmptyStation.line && x.quantity < 5 && x.location_state == LocationStateEnum.Empty.ToString() && x.enable).OrderBy(x => x.column).FirstOrDefault(); |
| | | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | |
| | | } |
| | | else |
| | | { |
| | | stationinfo = stationinfoRepository.Find(x => x.area == area && x.quantity > 0 /*&& x.location_state == LocationStateEnum.Stroge.ToString()*/ && x.enable).OrderBy(x => x.column).FirstOrDefault(); |
| | | stationinfo = stationinfoRepository.Find(x => x.area == area && x.quantity > 0 && x.enable).OrderBy(x => x.column).FirstOrDefault(); |
| | | if (stationinfo != null) |
| | | { |
| | | if (stationinfo.quantity < 5) return stationinfo; |
| | | else |
| | | stationinfo = stationinfoRepository.Find(x => x.area == area && x.quantity < 5 && x.location_state == LocationStateEnum.Empty.ToString() && x.enable).OrderByDescending(x => x.column).FirstOrDefault(); |
| | | stationinfo = stationinfoRepository.Find(x => x.area == area && x.location_state == LocationStateEnum.Empty.ToString() && x.enable).OrderByDescending(x => x.column).FirstOrDefault(); |
| | | } |
| | | else |
| | | { |
| | | stationinfo = stationinfoRepository.Find(x => x.area == area && x.location_state == LocationStateEnum.Empty.ToString() && x.enable).OrderByDescending(x => x.column).FirstOrDefault(); |
| | | } |
| | | |
| | | } |
| | |
| | | { |
| | | try |
| | | { |
| | | VOLContext context = new VOLContext(); |
| | | VOLContext context = new VOLContext(); |
| | | Idt_stationinfoRepository stationinfoRepository = new dt_stationinfoRepository(context); |
| | | Idt_agvtaskRepository agvtaskRepository = new dt_agvtaskRepository(context); |
| | | var stations = stationinfoRepository.Find(x => (x.stationCode.Contains("X")|| x.stationCode.Contains("W01001004") || x.stationCode.Contains("W01001005")) && x.location_state == "Abnormal" /*LocationStateEnum.Abnormal.ToString()*/ && (x.tray_type == "SmallTray/LargeTray" || x.tray_type == "LargeTray/SmallTray") && x.enable).ToList(); |
| | | Idt_agvtaskRepository agvtaskRepository = new dt_agvtaskRepository(context);//"Abnormal" |
| | | var stations = stationinfoRepository.Find(x => (x.stationCode.Contains("X") || x.stationCode.Contains("W01001004") || x.stationCode.Contains("W01001005")) && x.location_state == LocationStateEnum.Abnormal.ToString() && (x.tray_type == "SmallTray/LargeTray" || x.tray_type == "LargeTray/SmallTray") && x.enable).ToList(); |
| | | foreach (var station in stations) |
| | | { |
| | | if (agvtaskRepository.Find(x => x.agv_fromaddress == station.stationCode || x.agv_toaddress == station.stationCode).Any()) continue; |
| | |
| | | EmptyStation.location_state = LocationStateEnum.Busy.ToString(); |
| | | stationinfoRepository.Update(EmptyStation, true); |
| | | WriteDBLog.Success("åå»ºæ´æ¢ç©ºçä»»å¡", $"ä»»å¡ç¼å·ï¼{agvtask.agv_tasknum}", "PCS"); |
| | | CreatePartQueue(agvtaskRepository, agvtask, types[1]); |
| | | CreatePartQueue(agvtaskRepository, agvtask, agvtask.agv_Traytype == "SmallTray" ? "LargeTray" : "SmallTray"); |
| | | //CreatePartQueue(agvtaskRepository, agvtask, types[1]); |
| | | } |
| | | } |
| | | } |
| | |
| | | agv_toaddress = agvtask.agv_fromaddress, |
| | | agv_userid = "ç³»ç»", |
| | | agv_TrayStatus = agvtask.agv_TrayStatus, |
| | | agv_Traytype = type == "" ? agvtask.agv_Traytype : type, |
| | | agv_Traytype = type, |
| | | }; |
| | | agvtaskRepository.Add(taskPart, true); |
| | | WriteDBLog.Success("åå»ºæ´æ¢ç©ºçä»»å¡", $"ä»»å¡ç¼å·ï¼{taskPart.agv_tasknum}", "PCS"); |
| | |
| | | var tasks = agvtaskService.Find(x => x.agv_taskstate == "Queue").OrderByDescending(x => x.agv_grade).ThenBy(x => x.agv_createtime).ToList(); |
| | | foreach (var task in tasks) |
| | | { |
| | | if (task.agv_tasktype == "TaskType_EmptyPallet")//空æä»»å¡ |
| | | try |
| | | { |
| | | if (task.agv_fromaddress == "" && DateTime.Now - task.agv_createtime >= TimeSpan.FromMinutes(2)) |
| | | if (task.agv_tasktype == "TaskType_EmptyPallet")//空æä»»å¡ |
| | | { |
| | | if (task.agv_tasknum.Contains("_")) |
| | | if (task.agv_fromaddress == "" && DateTime.Now - task.agv_createtime >= TimeSpan.FromMinutes(2)) |
| | | { |
| | | string mainTaskNum = task.agv_tasknum.Split('_')[0]; |
| | | if (agvtaskService.Find(x => x.agv_tasknum == mainTaskNum && task.agv_taskstate != "Executing" && task.agv_taskstate != "Create").Any() || !agvtaskService.Find(x => x.agv_tasknum == mainTaskNum).Any()) |
| | | if (task.agv_tasknum.Contains("_")) |
| | | { |
| | | string mainTaskNum = task.agv_tasknum.Split('_')[0]; |
| | | if (agvtaskService.Find(x => x.agv_tasknum == mainTaskNum && task.agv_taskstate != "Executing" && task.agv_taskstate != "Create").Any() || !agvtaskService.Find(x => x.agv_tasknum == mainTaskNum).Any()) |
| | | GetStation.EmptyPalletStation(task); |
| | | } |
| | | else |
| | | GetStation.EmptyPalletStation(task); |
| | | |
| | | WriteDBLog.Success("æ´æ°ç©ºæéåä»»å¡", $"ä»»å¡ç¼å·ï¼{task.agv_tasknum}", "PCS"); |
| | | continue; |
| | | } |
| | | else |
| | | GetStation.EmptyPalletStation(task); |
| | | #region |
| | | //var Pipeline_client = PLCClient.Clients.FirstOrDefault(t => t.PLCName == "龿¡æº"); |
| | | //if (Pipeline_client == null) throw new Exception("龿¡æºè°åº¦æå¡æªå¼å¯ï¼"); |
| | | //if (!Pipeline_client.IsConnected) throw new Exception("ä¸é¾æ¡æºè¿æ¥è¶
æ¶ï¼"); |
| | | //var area = task.agv_Traytype == "SmallTray" ? "11" : "10"; |
| | | ////æ¾1åºåºç空æä½ |
| | | //var EmptyStation = stationinfoRepository.Find(x => x.area == area && x.quantity > 0 && x.stationCode.Contains("A") /*&& x.location_state == "Stroge"*//*LocationStateEnum.Stroge.ToString()*/ && x.enable).OrderBy(x => x.column).ThenBy(x => x.line).FirstOrDefault(); |
| | | //if (EmptyStation != null) |
| | | // if (EmptyStation.location_state == LocationStateEnum.Busy.ToString()) EmptyStation = null; |
| | | //#region ä¸ä¸ªåºååªè½æä¸ä¸ªç©ºæä»»å¡ |
| | | ////bool ok = false; |
| | | ////if (EmptyStation != null) |
| | | //// ok = agvtaskService.Find(x => x.agv_fromaddress == EmptyStation.stationCode || x.agv_toaddress == EmptyStation.stationCode).Any(); |
| | | ////if (EmptyStation == null || ok) |
| | | //// EmptyStation = stationinfoRepository.Find(x => x.area == area && x.quantity > 0 && x.stationCode.Contains(area == "10" ? "D" : "C") && x.location_state == "Stroge" /*LocationStateEnum.Stroge.ToString()*/ && x.enable) |
| | | //// .OrderBy(x => x.line).OrderByDescending(x => x.column).FirstOrDefault(); |
| | | //#endregion |
| | | //if (EmptyStation == null) |
| | | // EmptyStation = stationinfoRepository.Find(x => x.area == area && x.quantity > 0 && x.stationCode.Contains(area == "10" ? "D" : "C") && x.enable).OrderByDescending(x => x.column).FirstOrDefault(); |
| | | //if (EmptyStation == null) continue; |
| | | //#region åºå
åå¨ä»»å¡å ç¨ |
| | | //if (EmptyStation.location_state == LocationStateEnum.Busy.ToString()) |
| | | // continue; |
| | | //#endregion |
| | | |
| | | //if (EmptyStation == null) |
| | | // EmptyStation = stationinfoRepository.Find(x => x.area == area && x.quantity > 0 && x.stationCode.Contains(area == "10" ? "D" : "C") && x.location_state == "Stroge" && x.enable).OrderByDescending(x => x.column).FirstOrDefault(); |
| | | //if (EmptyStation != null) |
| | | //{ |
| | | // #region åºå
åå¨ä»»å¡å ç¨ |
| | | // //if (EmptyStation.location_state == LocationStateEnum.Busy.ToString()) |
| | | // // continue; |
| | | // #endregion |
| | | |
| | | // //if (agvtaskService.Find(x => x.agv_fromaddress == EmptyStation.stationCode || x.agv_toaddress == EmptyStation.stationCode).Any()) |
| | | // // return; |
| | | // #region è¡¥åºå
空æçï¼ä¸éè¦å
çµå¤æ |
| | | // var PalletSignal = Pipeline_client.ReadByOrder<Int16>("R_PalletSignal", task.agv_toaddress);//读åæçä¿¡å·:1:æ,2æ |
| | | // var MaterialSignal = Pipeline_client.ReadByOrder<Int16>("R_MaterialSignal", task.agv_toaddress);//读åè´§ç©ä¿¡å·:1:æ,2æ |
| | | // if (PalletSignal == 2 && MaterialSignal == 2) |
| | | // { |
| | | // task.agv_fromaddress = EmptyStation.stationCode; |
| | | // task.StarQuantity = EmptyStation.quantity - 1; |
| | | // task.agv_taskstate = "Create"; |
| | | // agvtaskService.Update(task, true); |
| | | // EmptyStation.location_state = LocationStateEnum.Busy.ToString(); |
| | | // stationinfoRepository.Update(EmptyStation, true); |
| | | // WriteDBLog.Success("æ´æ°ç©ºçéåä»»å¡", $"ä»»å¡ç¼å·ï¼{task.agv_tasknum}", "PCS"); |
| | | // } |
| | | // #endregion |
| | | //} |
| | | #endregion |
| | | } |
| | | } |
| | | else if (task.agv_tasktype == "TaskType_OutsourceInbound" || task.agv_tasktype == "TaskType_Inbound")//å¤ååºå
¥åº/ABåºå
¥åº |
| | | { |
| | | if (task.agv_toaddress == "") |
| | | else if (task.agv_tasktype == "TaskType_OutsourceInbound" || task.agv_tasktype == "TaskType_Inbound")//å¤ååºå
¥åº/ABåºå
¥åº |
| | | { |
| | | var stationinfo = stationinfoRepository.Find(x => x.stationCode == task.agv_fromaddress).FirstOrDefault(); |
| | | var work = workinfoRepository.Find(x => x.workOrder == stationinfo.Number && x.drawingNo == stationinfo.stationType && x.heatID == stationinfo.heatNumber && x.processCode == "17").FirstOrDefault(); |
| | | var TargetLocation = task.agv_tasktype == "TaskType_Inbound" ? GetLocation.GetEmptyLocation(stationinfoRepository, work, stationinfo) : StationTask.GetEmptyLocation(stationinfoRepository); |
| | | if (TargetLocation != null) |
| | | if (task.agv_toaddress == "") |
| | | { |
| | | if (agvtaskService.Find(x => x.agv_toaddress == TargetLocation.stationCode).Any()) continue; |
| | | task.agv_taskstate = "Create"; |
| | | task.agv_toaddress = TargetLocation.stationCode; |
| | | TargetLocation.location_state = LocationStateEnum.InBusy.ToString(); |
| | | TargetLocation.billetID = stationinfo.billetID; |
| | | TargetLocation.stationType = task.agv_materielid; |
| | | TargetLocation.heatNumber = stationinfo.heatNumber; |
| | | TargetLocation.Number = task.jobID; |
| | | stationinfoRepository.Update(TargetLocation, true); |
| | | agvtaskService.Update(task, true); |
| | | var stationinfo = stationinfoRepository.Find(x => x.stationCode == task.agv_fromaddress).FirstOrDefault(); |
| | | var work = workinfoRepository.Find(x => x.workOrder == stationinfo.Number && x.drawingNo == stationinfo.stationType && x.heatID == stationinfo.heatNumber && x.processCode == "17").FirstOrDefault(); |
| | | var TargetLocation = task.agv_tasktype == "TaskType_Inbound" ? GetLocation.GetEmptyLocation(stationinfoRepository, work, task) : StationTask.GetEmptyLocation(stationinfoRepository); |
| | | if (TargetLocation != null) |
| | | { |
| | | if (agvtaskService.Find(x => x.agv_toaddress == TargetLocation.stationCode).Any()) continue; |
| | | task.agv_taskstate = "Create"; |
| | | task.agv_toaddress = TargetLocation.stationCode; |
| | | TargetLocation.location_state = LocationStateEnum.InBusy.ToString(); |
| | | TargetLocation.billetID = stationinfo.billetID; |
| | | TargetLocation.stationType = task.agv_materielid; |
| | | TargetLocation.heatNumber = stationinfo.heatNumber; |
| | | TargetLocation.Number = task.jobID; |
| | | stationinfoRepository.Update(TargetLocation, true); |
| | | agvtaskService.Update(task, true); |
| | | WriteDBLog.Success("æ´æ°å
¥åºéåä»»å¡", $"ä»»å¡ç¼å·ï¼{task.agv_tasknum}", "PCS"); |
| | | continue; |
| | | } |
| | | } |
| | | } |
| | | else if (task.agv_tasktype == "TaskType_OutsourceOutbound" || task.agv_tasktype == "TaskType_Outbound")//å¤ååºåºåº/ABåºåºåº |
| | | { |
| | | if (task.agv_toaddress == "") |
| | | { |
| | | var EmptyStations = stationinfoRepository.Find(x => x.stationCode.Contains("S01001") && (x.tray_status == "EmptyTray" || x.location_state == "Empty") && x.enable).ToList(); |
| | | foreach (var EmptyStation in EmptyStations) |
| | | { |
| | | if (agvtaskService.Find(x => x.agv_toaddress == EmptyStation.stationCode).Any()) continue; |
| | | task.agv_taskstate = "Create"; |
| | | task.agv_toaddress = EmptyStation.stationCode; |
| | | EmptyStation.location_state = LocationStateEnum.Busy.ToString(); |
| | | stationinfoRepository.Update(EmptyStation, true); |
| | | agvtaskService.Update(task, true); |
| | | WriteDBLog.Success("æ´æ°åºåºéåä»»å¡", $"ä»»å¡ç¼å·ï¼{task.agv_tasknum}", "PCS"); |
| | | return; |
| | | } |
| | | } |
| | | } |
| | | else if (task.agv_tasktype == "TaskType_OutsourceCarry")//ç§»åºå¤å |
| | | { |
| | | if (task.agv_toaddress == "") |
| | | { |
| | | var TargetLocation = StationTask.GetEmptyLocation(stationinfoRepository); |
| | | if (TargetLocation != null) |
| | | { |
| | | if (agvtaskService.Find(x => x.agv_toaddress == TargetLocation.stationCode).Any()) continue; |
| | | |
| | | task.agv_taskstate = "Create"; |
| | | task.agv_toaddress = TargetLocation.stationCode; |
| | | TargetLocation.location_state = LocationStateEnum.OutBusy.ToString(); |
| | | TargetLocation.stationType = task.agv_materielid; |
| | | stationinfoRepository.Update(TargetLocation, true); |
| | | agvtaskService.Update(task, true); |
| | | WriteDBLog.Success("æ´æ°ç§»åºå¤åéåä»»å¡", $"ä»»å¡ç¼å·ï¼{task.agv_tasknum}", "PCS"); |
| | | continue; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | else if (task.agv_tasktype == "TaskType_OutsourceOutbound" || task.agv_tasktype == "TaskType_Outbound")//å¤ååºåºåº/ABåºåºåº |
| | | catch (Exception ex) |
| | | { |
| | | if (task.agv_toaddress == "") |
| | | { |
| | | var EmptyStations = stationinfoRepository.Find(x => x.stationCode.Contains("S01001") && x.tray_status == "EmptyTray" /*x.location_state == "Empty"*/ && x.enable).ToList(); |
| | | foreach (var EmptyStation in EmptyStations) |
| | | { |
| | | if (agvtaskService.Find(x => x.agv_toaddress == EmptyStation.stationCode).Any()) continue; |
| | | task.agv_taskstate = "Create"; |
| | | task.agv_toaddress = EmptyStation.stationCode; |
| | | EmptyStation.location_state = LocationStateEnum.Busy.ToString(); |
| | | stationinfoRepository.Update(EmptyStation, true); |
| | | agvtaskService.Update(task, true); |
| | | WriteDBLog.Success("æ´æ°åºåºéåä»»å¡", $"ä»»å¡ç¼å·ï¼{task.agv_tasknum}", "PCS"); |
| | | return; |
| | | } |
| | | } |
| | | } |
| | | else if (task.agv_tasktype == "TaskType_OutsourceCarry")//ç§»åºå¤å |
| | | { |
| | | if (task.agv_toaddress == "") |
| | | { |
| | | var TargetLocation = StationTask.GetEmptyLocation(stationinfoRepository); |
| | | if (TargetLocation != null) |
| | | { |
| | | if (agvtaskService.Find(x => x.agv_toaddress == TargetLocation.stationCode).Any()) continue; |
| | | |
| | | task.agv_taskstate = "Create"; |
| | | task.agv_toaddress = TargetLocation.stationCode; |
| | | TargetLocation.location_state = LocationStateEnum.OutBusy.ToString(); |
| | | TargetLocation.stationType = task.agv_materielid; |
| | | stationinfoRepository.Update(TargetLocation, true); |
| | | agvtaskService.Update(task, true); |
| | | WriteDBLog.Success("æ´æ°åºåºéåä»»å¡", $"ä»»å¡ç¼å·ï¼{task.agv_tasknum}", "PCS"); |
| | | return; |
| | | } |
| | | } |
| | | //WriteDBLog.Error("æ´æ°éåä»»å¡", $"é误信æ¯ï¼{ex.Message}", "PCS"); |
| | | WriteLog.Write_Log("æ´æ°éåä»»å¡","æ´æ°å¤±è´¥", "", $"é误信æ¯ï¼{ex.Message}"); |
| | | } |
| | | } |
| | | } |
| | |
| | | /// <param name="mesinfo"></param> |
| | | /// <param name="stationinfo"></param> |
| | | /// <returns></returns> |
| | | public static dt_stationinfo GetEmptyLocation(Idt_stationinfoRepository stationinfoRepository, VV_Mes_Workinfo mesinfo, dt_stationinfo stationinfo) |
| | | public static dt_stationinfo GetEmptyLocation(Idt_stationinfoRepository stationinfoRepository, VV_Mes_Workinfo mesinfo, dt_agvtask agvtask) |
| | | { |
| | | lock (GetEmptyLocationobj) |
| | | { |
| | |
| | | VOLContext context = new VOLContext(); |
| | | Idt_inventoryRepository inventoryRepository = new dt_inventoryRepository(context); |
| | | string area1 = ""; |
| | | if (stationinfo.tray_type == "LargeTray") |
| | | if (agvtask.agv_Traytype == "LargeTray") |
| | | area1 = "4"; |
| | | |
| | | #region æ¥æ¾åºå |
| | | dt_inventory inventory = null; |
| | | inventory = inventoryRepository.Find(x => x.FigureNumber == stationinfo.stationType).OrderByDescending(x => x.OnlineTime).FirstOrDefault(); |
| | | inventory = inventoryRepository.Find(x => x.FigureNumber == agvtask.agv_materielid).OrderByDescending(x => x.OnlineTime).FirstOrDefault(); |
| | | #endregion |
| | | |
| | | dt_stationinfo TargetLocation = null; |
| | |
| | | if (!string.IsNullOrEmpty(area1) && station.area != area1)//å
¥å¤§æçåºåº |
| | | { |
| | | #region 寻æ¾å·²åé
åå¾å·å
¥åºä»»å¡åºä½ |
| | | TargetLocation = stationinfoRepository.Find(x => x.stationType == stationinfo.stationType && x.location_state == LocationStateEnum.InBusy.ToString() && x.area == area1).FirstOrDefault(); |
| | | TargetLocation = stationinfoRepository.Find(x => x.stationType == agvtask.agv_materielid && x.location_state == LocationStateEnum.InBusy.ToString() && x.area == area1).FirstOrDefault(); |
| | | if (TargetLocation != null) |
| | | { |
| | | TargetLocation = stationinfoRepository.Find(x => x.line == TargetLocation.line && x.location_state == LocationStateEnum.Empty.ToString() && x.enable && x.area == TargetLocation.area).OrderBy(x => x.column).FirstOrDefault(); |
| | |
| | | var TargetLocations1 = stationinfoRepository.Find(x => x.location_state == LocationStateEnum.Empty.ToString() && x.enable && x.area == area1).OrderBy(x => x.line).ThenBy(x => x.column).ToList(); |
| | | foreach (var Location in TargetLocations1) |
| | | { |
| | | if (!stationinfoRepository.Find(x => x.line == Location.line && x.area == Location.area && x.stationType == stationinfo.stationType && x.location_state == LocationStateEnum.OutBusy.ToString()).Any()) return Location; |
| | | if (!stationinfoRepository.Find(x => x.line == Location.line && x.area == Location.area && x.stationType == agvtask.agv_materielid && x.location_state == LocationStateEnum.OutBusy.ToString()).Any()) return Location; |
| | | } |
| | | #endregion |
| | | |
| | |
| | | #endregion |
| | | |
| | | #region 寻æ¾å·²åé
åå¾å·å
¥åºä»»å¡åºä½ |
| | | TargetLocation = stationinfoRepository.Find(x => x.stationType == stationinfo.stationType && x.location_state == LocationStateEnum.InBusy.ToString() && (x.area == "1" || x.area == "2" || x.area == "3" || x.area == "4")).FirstOrDefault(); |
| | | TargetLocation = stationinfoRepository.Find(x => x.stationType == agvtask.agv_materielid && x.location_state == LocationStateEnum.InBusy.ToString() && (x.area == "1" || x.area == "2" || x.area == "3" || x.area == "4")).FirstOrDefault(); |
| | | if (TargetLocation != null) |
| | | { |
| | | if (TargetLocation.area == "1") |
| | |
| | | { |
| | | if (Location.area == "1") |
| | | { |
| | | if (stationinfoRepository.Find(x => x.column == Location.column && x.area == Location.area && x.stationType == stationinfo.stationType && x.location_state != LocationStateEnum.OutBusy.ToString()).Any()) return Location; |
| | | if (stationinfoRepository.Find(x => x.column == Location.column && x.area == Location.area && x.stationType == agvtask.agv_materielid && x.location_state != LocationStateEnum.OutBusy.ToString()).Any()) return Location; |
| | | } |
| | | else |
| | | { |
| | | if (!stationinfoRepository.Find(x => x.line == Location.line && x.area == Location.area && x.stationType == stationinfo.stationType && x.location_state == LocationStateEnum.OutBusy.ToString()).Any()) return Location; |
| | | if (!stationinfoRepository.Find(x => x.line == Location.line && x.area == Location.area && x.stationType == agvtask.agv_materielid && x.location_state == LocationStateEnum.OutBusy.ToString()).Any()) return Location; |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region æªæ¾å°åºåæå½ååºåè¡å·²æ»¡,å¯»æ¾æ°çä¸è¡ |
| | | var area = GetArea(mesinfo.quantity, stationinfo.tray_type); |
| | | var area = GetArea(mesinfo.quantity, agvtask.agv_Traytype); |
| | | TargetLocation = stationinfoRepository.Find(x => x.column == 1 && x.area == area && x.location_state == LocationStateEnum.Empty.ToString() && x.enable).OrderBy(x => x.line).ThenBy(x => x.column).FirstOrDefault(); |
| | | if (TargetLocation == null && area != "4") |
| | | { |
| | |
| | | "Connection": { |
| | | "DBType": "MsSql", //MySql/MsSql/PgSql //æ°æ®åºç±»åï¼å¦æä½¿ç¨çæ¯sqlserveræ¤å¤åºè®¾ç½®ä¸ºMsSql |
| | | //sqlserverè¿æ¥å符串P@ssw0rd |
| | | //"DbConnectionString": "Data Source=192.168.12.101;Initial Catalog=WIDESEA_DB;Persist Security Info=True;User ID=sa;Password=123456;Connect Timeout=500;", |
| | | "DbConnectionString": "Data Source=.;Initial Catalog=WIDESEA_DB;Persist Security Info=True;User ID=sa;Password=P@ssw0rd;Connect Timeout=500;", |
| | | |
| | | //mysqlè¿æ¥å符串(å级EFCore3.1å°æ¶å·²å°mysqlè¿æ¥å符串修æ¹,2019-12-20) |
| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// å¤åè´§ä½æ«ç ç¡®è®¤ç©æå·²è¢«åèµ° |
| | | /// </summary> |
| | | /// <param name="saveModel"></param> |
| | | /// <returns></returns> |
| | | [HttpPost, Route("Confirmedcut")] |
| | | public WebResponseContent Confirmedcut([FromBody] SaveModel saveModel) |
| | | { |
| | | return new ToMesServer().Confirmedcut(saveModel); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// è·åè´§ä½ |
| | | /// </summary> |
| | | /// <param name="request"></param> |