| | |
| | | using StackExchange.Redis; |
| | | using FreeSql.Internal.Model; |
| | | using StackExchange.Redis; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using WIDESEA_Comm; |
| | | using WIDESEA_Comm.LogInfo; |
| | | using WIDESEA_Core.EFDbContext; |
| | | using WIDESEA_Core.FreeDB; |
| | | using WIDESEA_WCS.IRepositories; |
| | | using WIDESEA_WCS.Repositories; |
| | | using WIDESEA_WCS.WCSClient; |
| | |
| | | { |
| | | public class Gantry |
| | | { |
| | | static 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_geometry_data_detectionlineRepository detectionlineRepository = new dt_geometry_data_detectionlineRepository(Context); |
| | | Idt_stationinfoRepository stationinfoRepository = new dt_stationinfoRepository(Context); |
| | | Idt_mes_detailRepository mes_DetailRepository = new dt_mes_detailRepository(Context); |
| | | Idt_mes_headRepository mes_HeadRepository = new dt_mes_headRepository(Context); |
| | | Idt_patternRepository patternRepository = new dt_patternRepository(Context); |
| | | //FreeDB freeDB = new FreeDB(); |
| | | //static 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_geometry_data_detectionlineRepository detectionlineRepository = new dt_geometry_data_detectionlineRepository(Context); |
| | | ////Idt_stationinfoRepository stationinfoRepository = new dt_stationinfoRepository(Context); |
| | | //Idt_mes_detailRepository mes_DetailRepository = new dt_mes_detailRepository(Context); |
| | | //Idt_mes_headRepository mes_HeadRepository = new dt_mes_headRepository(Context); |
| | | //Idt_patternRepository patternRepository = new dt_patternRepository(Context); |
| | | #region æ¥è¯¢è½¦è½®æ°æ® |
| | | public void QueryWheeldata(PLCClient client) |
| | | { |
| | | 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_geometry_data_detectionlineRepository detectionlineRepository = new dt_geometry_data_detectionlineRepository(Context); |
| | | var plc = repository.FindFirst(x => x.plcinfo_name == client.PLCName); |
| | | List<string> names = new List<string>() { "1åå
è¾é䏿æ¥è¯¢è½¦è½®", "2åå
è¾é䏿æ¥è¯¢è½¦è½®", "3åå
è¾é䏿æ¥è¯¢è½¦è½®", "è¾é䏿æ¥è¯¢è½¦è½®" }; |
| | | foreach (string name in names) |
| | |
| | | //1-æ¾å°æ°æ®ï¼2-æªæ¾å°å·¥ä»¶ç±»åæ°æ® |
| | | client.WriteByOrder("W_i_status", (byte)2, name); |
| | | client.WriteByOrder("R_oi_on", (byte)0, name); |
| | | #region æ¥å¿è®°å½ |
| | | WriteDBLog.Error(name, $"è¯»åæ¡æ¶ä¿¡æ¯ï¼\nè½®åIDï¼{wp_type}\n\nåå
¥æ¡æ¶ä¿¡æ¯ï¼\nW_i_statusï¼2\nR_oi_onï¼0\n\næªæ¥è¯¢å°æºå 工车轮信æ¯", "PCS"); |
| | | #endregion |
| | | } |
| | | else |
| | | { |
| | |
| | | client.WriteByOrder("W_i_parameter_g", (float)geometry.g, name); |
| | | client.WriteByOrder("W_i_parameter_h", (float)geometry.h, name); |
| | | client.WriteByOrder("R_oi_on", (byte)0, name); |
| | | #region æ¥å¿è®°å½ |
| | | WriteDBLog.Success(name, $"è¯»åæ¡æ¶ä¿¡æ¯ï¼\nè½®åIDï¼{wp_type}\n\nåå
¥æ¡æ¶ä¿¡æ¯ï¼\nW_i_statusï¼1" + $"\naï¼{(float)geometry.a}\nbï¼{(float)geometry.b}\ncï¼{(float)geometry.c}\n" + |
| | | $"dï¼{(float)geometry.d}\neï¼{(float)geometry.e}\nfï¼{(float)geometry.f}\ngï¼{(float)geometry.g}\nhï¼{(float)geometry.h}\nR_oi_onï¼0", "PCS"); |
| | | #endregion |
| | | } |
| | | } |
| | | else |
| | |
| | | { |
| | | client.WriteByOrder("W_i_status", (byte)2, name); |
| | | client.WriteByOrder("R_oi_on", (byte)0, name); |
| | | #region æ¥å¿è®°å½ |
| | | WriteDBLog.Error(name, $"è¯»åæ¡æ¶ä¿¡æ¯ï¼\nè½®åIDï¼{wp_type}\n\nåå
¥æ¡æ¶ä¿¡æ¯ï¼\nW_i_statusï¼2\nR_oi_onï¼0\n\næªæ¥è¯¢å°æ£æµçº¿è½¦è½®ä¿¡æ¯", "PCS"); |
| | | #endregion |
| | | } |
| | | else |
| | | { |
| | |
| | | client.WriteByOrder("W_i_parameter_g", (float)geometry.g, name); |
| | | client.WriteByOrder("W_i_parameter_h", (float)geometry.h, name); |
| | | client.WriteByOrder("R_oi_on", (byte)0, name); |
| | | #region æ¥å¿è®°å½ |
| | | WriteDBLog.Success(name, $"è¯»åæ¡æ¶ä¿¡æ¯ï¼\nè½®åIDï¼{wp_type}\n\nåå
¥æ¡æ¶ä¿¡æ¯ï¼\nW_i_statusï¼1" + $"\naï¼{(float)geometry.a}\nbï¼{(float)geometry.b}\ncï¼{(float)geometry.c}\n" + |
| | | $"dï¼{(float)geometry.d}\neï¼{(float)geometry.e}\nfï¼{(float)geometry.f}\ngï¼{(float)geometry.g}\nhï¼{(float)geometry.h}\nR_oi_onï¼0", "PCS"); |
| | | #endregion |
| | | } |
| | | } |
| | | |
| | |
| | | { |
| | | 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_geometry_data_detectionlineRepository detectionlineRepository = new dt_geometry_data_detectionlineRepository(Context); |
| | | Idt_mes_detailRepository mes_DetailRepository = new dt_mes_detailRepository(Context); |
| | | Idt_mes_headRepository mes_HeadRepository = new dt_mes_headRepository(Context); |
| | | Idt_patternRepository patternRepository = new dt_patternRepository(Context); |
| | | var plc = repository.FindFirst(x => x.plcinfo_name == client.PLCName); |
| | | List<string> names = new List<string>() { "1åå
è¾é䏿æ¥è¯¢è®¢å", "2åå
è¾é䏿æ¥è¯¢è®¢å", "3åå
è¾é䏿æ¥è¯¢è®¢å", "è¾é䏿æ¥è¯¢è®¢å" }; |
| | | foreach (string name in names) |
| | | { |
| | | var details = plcRepository.Find(x => x.plcdetail_iotype == plc.plcinfo_iotyep && x.plcdetail_number == name).ToList(); |
| | | var on = DBExtension.Read(details.Where(x => x.plcdetail_name == "R_oi_on").First(), client); |
| | | //var on = DBExtension.Read(details.Where(x => x.plcdetail_name == "R_oi_on" && x.plcdetail_number == name).First(), client); |
| | | if ((byte)on == 1) |
| | | { |
| | | //var wp_id = DBExtension.Read(details.Where(x => x.plcdetail_name == "R_o_wp_id").First(), client).ToString(); |
| | | var wp_id = client.ReadByOrder<string>("R_o_wp_id", name); |
| | | if (string.IsNullOrEmpty(wp_id)) |
| | | { |
| | | #region æ¥å¿è®°å½ |
| | | client.WriteByOrder("W_i_status", (byte)2, name); |
| | | client.WriteByOrder("R_oi_on", (byte)0, name); |
| | | WriteDBLog.Error(name, $"è¯»åæ¡æ¶ä¿¡æ¯ï¼\n车轮SNï¼{wp_id}\n\nåå
¥æ¡æ¶ä¿¡æ¯ï¼\nW_i_statusï¼2\nR_oi_onï¼0\n\n车轮SNå·ä¸ºç©º", "PCS"); |
| | | #endregion |
| | | continue; |
| | | } |
| | | var wp_type = DBExtension.Read(details.Where(x => x.plcdetail_name == "R_o_wp_type").First(), client); |
| | | var mes_Detail = mes_DetailRepository.FindFirst(x => x.SN == wp_id); |
| | | #region æµè¯ä½¿ç¨ |
| | | if (mes_Detail == null) |
| | | { |
| | | mes_Detail = mes_DetailRepository.FindFirst(x => x.jobID == (name == "3åå
è¾é䏿æ¥è¯¢è®¢å" ? "01180127004-2" : "01180127004-1")); |
| | | mes_Detail.SN = wp_id; |
| | | mes_DetailRepository.Update(mes_Detail, true); |
| | | } |
| | | #endregion |
| | | if (mes_Detail == null) |
| | | { |
| | | client.WriteByOrder("W_i_status", (byte)2, name); |
| | | client.WriteByOrder("R_oi_on", (byte)0, name); |
| | | #region æ¥å¿è®°å½ |
| | | WriteDBLog.Error(name, $"è¯»åæ¡æ¶ä¿¡æ¯ï¼\n车轮SNï¼{wp_id}\n\nåå
¥æ¡æ¶ä¿¡æ¯ï¼\nW_i_statusï¼2\nR_oi_onï¼0\n\næªæ¥è¯¢å°å·¥å详æ
", "PCS"); |
| | | #endregion |
| | | continue; |
| | | } |
| | | var mes_Head = mes_HeadRepository.FindFirst(x => x.jobID == mes_Detail.jobID); |
| | |
| | | { |
| | | client.WriteByOrder("W_i_status", (byte)2, name); |
| | | client.WriteByOrder("R_oi_on", (byte)0, name); |
| | | #region æ¥å¿è®°å½ |
| | | WriteDBLog.Error(name, $"è¯»åæ¡æ¶ä¿¡æ¯ï¼\n车轮SNï¼{wp_id}\n\nåå
¥æ¡æ¶ä¿¡æ¯ï¼\nW_i_statusï¼2\nR_oi_onï¼0\n\næªæ¥è¯¢å°å·¥å头表", "PCS"); |
| | | #endregion |
| | | continue; |
| | | } |
| | | |
| | |
| | | { |
| | | client.WriteByOrder("W_i_status", (byte)4, name); |
| | | client.WriteByOrder("R_oi_on", (byte)0, name); |
| | | #region æ¥å¿è®°å½ |
| | | WriteDBLog.Error(name, $"è¯»åæ¡æ¶ä¿¡æ¯ï¼\n车轮SNï¼{wp_id}\n\nåå
¥æ¡æ¶ä¿¡æ¯ï¼\nW_i_statusï¼4\nR_oi_onï¼0\n\næå¨å
¥åºæ¨¡å¼æªéæ©åºåº", "PCS"); |
| | | #endregion |
| | | continue; |
| | | } |
| | | var wp_type = DBExtension.Read(details.Where(x => x.plcdetail_name == "R_o_wp_type").First(), client); |
| | | //var geometry = dataRepository.FindFirst(x => x.TypeId == (Int32)wp_type); |
| | | var geometry = dataRepository.FindFirst(x => x.Description == mes_Head.drawingNo); |
| | | var geometry = dataRepository.Find(x => x.Description == mes_Head.drawingNo && x.TypeId == (Int32)wp_type).FirstOrDefault(); |
| | | if (geometry == null) |
| | | { |
| | | //1-好,å
许å å·¥ï¼2-ä¸å¨å表ä¸ï¼3-ä¸å 工车轮类åï¼4-æå¨å
¥åºæ¨¡å¼äººå·¥æªéæ©åºåº |
| | | client.WriteByOrder("W_i_status", (byte)2, name); |
| | | client.WriteByOrder("R_oi_on", (byte)0, name); |
| | | #region æ¥å¿è®°å½ |
| | | WriteDBLog.Error(name, $"è¯»åæ¡æ¶ä¿¡æ¯ï¼\n车轮SNï¼{wp_id}\nè½®åIDï¼{wp_type}\n\nåå
¥æ¡æ¶ä¿¡æ¯ï¼\nW_i_statusï¼2\nR_oi_onï¼0\n\næªæ¥è¯¢å°æºå 工车轮信æ¯", "PCS"); |
| | | #endregion |
| | | continue; |
| | | } |
| | | else |
| | |
| | | //å±è½å·¥èº(å±è½è§è§æ£æµ/å±è½æ¶æ²¹) |
| | | //if (name != "è¾é䏿æ¥è¯¢è½¦è½®") |
| | | //{ |
| | | client.WriteByOrder("W_i_skip_op_SJ1", mes_Head.skip_op_1, name);//å±è½è§è§æ£æµè®¾å¤1 |
| | | client.WriteByOrder("W_i_skip_op_SJ2", mes_Head.skip_op_2, name);//å±è½è§è§æ£æµè®¾å¤2 |
| | | client.WriteByOrder("W_i_skip_op_SJ1", name == "3åå
è¾é䏿æ¥è¯¢è®¢å" ? true : mes_Head.skip_op_1, name);//å±è½è§è§æ£æµè®¾å¤1 |
| | | client.WriteByOrder("W_i_skip_op_SJ2", name == "3åå
è¾é䏿æ¥è¯¢è®¢å" ? true : mes_Head.skip_op_2, name);//å±è½è§è§æ£æµè®¾å¤2 |
| | | client.WriteByOrder("W_i_skip_op_LT", mes_Head.skip_op_3, name);//å±è½é¾æ¡æº |
| | | //} |
| | | client.WriteByOrder("R_oi_on", (byte)0, name); |
| | | |
| | | #region æ¥å¿è®°å½ |
| | | WriteDBLog.Success(name, $"è¯»åæ¡æ¶ä¿¡æ¯ï¼\n车轮SNï¼{wp_id}\nè½®åIDï¼{wp_type}\n\nåå
¥æ¡æ¶ä¿¡æ¯ï¼\nW_i_statusï¼1" + |
| | | $"\nW_i_job_idï¼{mes_Detail.jobID}\nW_i_drawing_idï¼{mes_Head.drawingNo}\nW_i_heat_idï¼{mes_Detail.heatID}\nW_i_batch_idï¼{mes_Detail.heatBatchID}" + |
| | | $"\nW_i_skip_op_SJ1ï¼{(name == "3åå
è¾é䏿æ¥è¯¢è®¢å" ? true : mes_Head.skip_op_1)}\nW_i_skip_op_SJ2ï¼{(name == "3åå
è¾é䏿æ¥è¯¢è®¢å" ? true : mes_Head.skip_op_2)}" + |
| | | $"\nW_i_skip_op_LTï¼{mes_Head.skip_op_3}\nR_oi_onï¼0", "PCS"); |
| | | #endregion |
| | | } |
| | | } |
| | | else |
| | | { |
| | | var geometry = dataRepository.FindFirst(x => x.Description == mes_Head.drawingNo); |
| | | var geometry = detectionlineRepository.Find(x => x.Description == mes_Head.drawingNo && x.TypeId == (Int32)wp_type).FirstOrDefault(); |
| | | if (geometry == null) |
| | | { |
| | | //1-好,å
许å å·¥ï¼2-ä¸å¨å表ä¸ï¼3-ä¸å 工车轮类åï¼4-æå¨å
¥åºæ¨¡å¼äººå·¥æªéæ©åºåº |
| | | client.WriteByOrder("W_i_status", (byte)2, name); |
| | | client.WriteByOrder("R_oi_on", (byte)0, name); |
| | | #region æ¥å¿è®°å½ |
| | | WriteDBLog.Error(name, $"è¯»åæ¡æ¶ä¿¡æ¯ï¼\n车轮SNï¼{wp_id}\nè½®åIDï¼{wp_type}\n\nåå
¥æ¡æ¶ä¿¡æ¯ï¼\nW_i_statusï¼2\nR_oi_onï¼0\n\næªæ¥è¯¢å°æ£æµçº¿è½¦è½®ä¿¡æ¯", "PCS"); |
| | | #endregion |
| | | continue; |
| | | } |
| | | else |
| | |
| | | //client.WriteByOrder("W_i_sourceheat", "", name); |
| | | client.WriteByOrder("W_i_batch_id", mes_Detail.heatBatchID, name); |
| | | client.WriteByOrder("R_oi_on", (byte)0, name); |
| | | #region æ¥å¿è®°å½ |
| | | WriteDBLog.Success(name, $"è¯»åæ¡æ¶ä¿¡æ¯ï¼\n车轮SNï¼{wp_id}\nè½®åIDï¼{wp_type}\n\nåå
¥æ¡æ¶ä¿¡æ¯ï¼\nW_i_statusï¼1" + $"\nW_i_job_idï¼{mes_Detail.jobID}" + |
| | | $"\nW_i_drawing_idï¼{mes_Head.drawingNo}\nW_i_heat_idï¼{mes_Detail.heatID}\nW_i_batch_idï¼{mes_Detail.heatBatchID}\nR_oi_onï¼0", "PCS"); |
| | | #endregion |
| | | } |
| | | } |
| | | |
| | |
| | | { |
| | | try |
| | | { |
| | | VOLContext Context = new VOLContext(); |
| | | Idt_plcinfoheadRepository repository = new dt_plcinfoheadRepository(Context); |
| | | Idt_plcinfodetailRepository plcRepository = new dt_plcinfodetailRepository(Context); |
| | | Idt_stationinfoRepository stationinfoRepository = new dt_stationinfoRepository(Context); |
| | | Idt_geometry_dataRepository dataRepository = new dt_geometry_dataRepository(Context); |
| | | Idt_geometry_data_detectionlineRepository detectionlineRepository = new dt_geometry_data_detectionlineRepository(Context); |
| | | Idt_mes_detailRepository mes_DetailRepository = new dt_mes_detailRepository(Context); |
| | | Idt_mes_headRepository mes_HeadRepository = new dt_mes_headRepository(Context); |
| | | Idt_patternRepository patternRepository = new dt_patternRepository(Context); |
| | | var plc = repository.FindFirst(x => x.plcinfo_name == client.PLCName); |
| | | var Pipeline_client = PLCClient.Clients.FirstOrDefault(t => t.PLCName == "龿¡æº"); |
| | | if (Pipeline_client == null) throw new Exception("龿¡æºè°åº¦æå¡æªå¼å¯ï¼"); |
| | | if (!Pipeline_client.IsConnected) throw new Exception("ä¸é¾æ¡æºè¿æ¥è¶
æ¶ï¼"); |
| | | var Pipelineplc = repository.FindFirst(x => x.plcinfo_name == Pipeline_client.PLCName); |
| | | List<string> names = new List<string>() { "1åå
䏿åº", "2åå
䏿åº", "3åå
䏿åº" }; |
| | | |
| | | foreach (string name in names) |
| | | { |
| | | var details = plcRepository.Find(x => x.plcdetail_iotype == plc.plcinfo_iotyep && x.plcdetail_number == name).ToList(); |
| | | |
| | | 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; |
| | | } |
| | | |
| | | |
| | | 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);//è´§ä½ç¶ææ´æ° |
| | | if (!finished && updatefinished) |
| | | { |
| | | client.WriteByOrder("W_Storage_update", false, name);//è´§ä½ç¶ææ´æ° |
| | | #region æ¥å¿è®°å½ |
| | | WriteDBLog.Success(name + "è´§ä½ç¶ææ´æ°å¤ä½", $"è¯»åæ¡æ¶ä¿¡æ¯ï¼\n车轮SNï¼{Wheel_id}\nè½®åIDï¼{Wheel_Type}\n\nåå
¥æ¡æ¶ä¿¡æ¯ï¼\nW_Storage_updateï¼false", "PCS"); |
| | | #endregion |
| | | } |
| | | if (finished && !updatefinished) |
| | | { |
| | | var AreaNr = (Int16)DBExtension.Read(details.Where(x => x.plcdetail_name == "W_AreaNr").First(), client); |
| | | var areaCode = PipelineJob.area_code(name); //æ ¹æ®ä¸æå£åå
åè·ååºå代ç |
| | | var station = stationinfoRepository.FindFirst(x => x.area == areaCode && x.stationCode.Substring(x.stationCode.Length - 1, 1) == AreaNr.ToString()); //æ¤å¤æé®é¢ ä¸ç¥éæ¯ç»å°¾ä¸º1çåªä¸ªä¸æå£ |
| | | station.quantity++; //todo æ¤å¤æ°éä¸ä¼å¢å 使¯æ´æ°å®ä½å½±åæ¥é ææ¥æµè¯ |
| | | if (station.quantity > 5) |
| | | throw new Exception($"䏿ä½ä¿¡æ¯æ´æ°å¤±è´¥ï¼ä¸æä½è½¦è½®æ°é大äº5ï¼{station.stationCode}"); |
| | | //station.bindSN = station.bindSN == string.Empty ? Wheel_id : station.bindSN + "," + Wheel_id; |
| | | station.bindSN = string.IsNullOrEmpty(station.bindSN) ? Wheel_id : station.bindSN + "," + Wheel_id; |
| | | if (station.quantity == 1) |
| | | { |
| | | station.stationType = mes_Head.drawingNo; |
| | | station.Number = mes_Head.jobID; |
| | | station.heatNumber = mes_Detail.heatID; |
| | | station.tray_status = "StrogeTray"; |
| | | } |
| | | var count = stationinfoRepository.Update(station, true); |
| | | if (count < 1) |
| | | throw new Exception($"䏿ä½ä¿¡æ¯æ´æ°å¤±è´¥ï¼ä¸æä½ç¼å·ï¼{station.stationCode}"); |
| | | client.WriteByOrder("W_Storage_update", true, name);//è´§ä½ç¶ææ´æ° |
| | | client.WriteByOrder("W_Enabl_Load", false, name);//æ¯å¦å
许 |
| | | #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 |
| | | } |
| | | |
| | | var Request = (bool)DBExtension.Read(details.Where(x => x.plcdetail_name == "R_Request_Load").First(), client); |
| | | if (!Request) continue; |
| | |
| | | var NGStation = "X01001003"; |
| | | if (name == "2åå
䏿åº") NGStation = "X02001003"; |
| | | if (name == "3åå
䏿åº") NGStation = "X03001002"; |
| | | foreach (var station in Stations) |
| | | |
| | | foreach (var station in Stations) //ä»»ä½ä¸ä¸ªä¸æä½ä¸ºç©ºæç¦ç¨æ¶,é½ä¼åæ¢æ¡æ¶ |
| | | { |
| | | if (!station.enable || station.location_state == LocationStateEnum.Empty.ToString()) |
| | | client.WriteByOrder("W_Enabl_Load", false, name);//ä¿¡å·ä¸ºfalseæ¡æ¶åæ¢è¿å
¥ |
| | | } |
| | | 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å· |
| | | //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); |
| | | var mes_Head = mes_HeadRepository.FindFirst(x => x.jobID == mes_Detail.jobID); |
| | | //var currentAreaNr = (Int16)DBExtension.Read(details.Where(x => x.plcdetail_name == "W_Are00aNr").First(), client); |
| | | //var currentAreaCode = PipelineJob.area_code(name); //æ ¹æ®ä¸æå£åå
åè·ååºå代ç |
| | | //var currentStation = stationinfoRepository.FindFirst(x => x.area == currentAreaCode && x.stationCode.Substring(x.stationCode.Length - 1, 1) == currentAreaNr.ToString()); |
| | | //if (!currentStation.enable || currentStation.location_state == LocationStateEnum.Empty.ToString()) |
| | | // client.WriteByOrder("W_Enabl_Load", false, name);//ä¿¡å·ä¸ºfalseæ¡æ¶åæ¢è¿å
¥ |
| | | |
| | | var wheel = PipelineJob.QueryMateriel(mes_Head.drawingNo); |
| | | if (wheel == null) |
| | | { |
| | | #region æ¥å¿è®°å½ |
| | | WriteDBLog.Error(name, $"æªæ¥è¯¢å°è½¦è½®ä¿¡æ¯ï¼", "PCS"); |
| | | #endregion |
| | | continue; |
| | | } |
| | | |
| | | var PartStatus = DBExtension.Read(details.Where(x => x.plcdetail_name == "R_PartStatus").First(), client);//1:ok;2:nok |
| | | if ((Int16)PartStatus == 1) |
| | |
| | | Stationinfo = Stations.Where(x => x.enable && x.stationCode != NGStation && x.location_state == LocationStateEnum.Stroge.ToString() && x.quantity == 0).FirstOrDefault(); |
| | | if (Stationinfo != null) |
| | | { |
| | | #region æçç±»åä¸ä¸è´éæ´æ¢æç |
| | | if (Stationinfo.tray_type != (wheel.e < 1100 ? "SmallTray" : "LargeTray")) |
| | | { |
| | | Stationinfo.location_state = LocationStateEnum.Abnormal.ToString(); |
| | | Stationinfo.tray_type = Stationinfo.tray_type == "SmallTray" ? "SmallTray/LargeTray" : "LargeTray/SmallTray"; |
| | | Stationinfo.remark = "æçç±»åä¸ä¸è´éæ´æ¢æç"; |
| | | stationinfoRepository.Update(Stationinfo, true); |
| | | continue; |
| | | } |
| | | #endregion |
| | | |
| | | var Pipelinedetails = plcRepository.Find(x => x.plcdetail_iotype == Pipelineplc.plcinfo_iotyep && x.plcdetail_number == Stationinfo.stationCode).ToList(); |
| | | var PalletSignal = (Int16)DBExtension.Read(Pipelinedetails.Where(x => x.plcdetail_name == "R_PalletSignal").First(), Pipeline_client);//读åæçä¿¡å·:1:æ,2æ |
| | | //var MaterialSignal = (Int16)DBExtension.Read(details.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) |
| | | { |
| | | var SNS = Stationinfo.bindSN.Split(","); |
| | | List<string> list = new List<string>(); |
| | | foreach (var SN in SNS) |
| | | if (Stationinfo.bindSN != null) |
| | | { |
| | | if (!string.IsNullOrEmpty(SN)) |
| | | list.Add(SN); |
| | | var SNS = Stationinfo.bindSN.Split(","); |
| | | foreach (var SN in SNS) |
| | | { |
| | | if (!string.IsNullOrEmpty(SN)) |
| | | list.Add(SN); |
| | | } |
| | | } |
| | | |
| | | //ç¼åæ¶ä¸è½¦è½®æ°éä¸SNå·æ°éä¸ä¸è´ |
| | | if (list.Count != Stationinfo.quantity) |
| | | { |
| | | Stationinfo.location_state = LocationStateEnum.Abnormal.ToString(); |
| | | Stationinfo.remark = "车轮æ°éä¸SNå·æ°éä¸ä¸è´"; |
| | | stationinfoRepository.Update(Stationinfo, true); |
| | | continue; |
| | | //åå
¥æ¡æ¶æ¥è¦ä¿¡å· |
| | | throw new Exception("䏿ä½è½¦è½®æ°éä¸SNå·æ°éä¸ä¸è´ï¼ä¸æä½ç¼å·ï¼" + Stationinfo.stationCode); |
| | | //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);//åºåè´§ä½å· |
| | | client.WriteByOrder("W_IndexNr", (Int16)(Stationinfo.quantity + 1), name);//æçä¸ç第å 个车轮 |
| | | client.WriteByOrder("W_Storage_Type", (Int16)1, name);//æçç±»å1-横æ¾;2-ç«æ¾(ææ¶åªææ¨ªæ¾æç) |
| | | client.WriteByOrder("W_Enabl_Load", true, name);//æ¯å¦å
许 |
| | | #region æ¥å¿è®°å½ |
| | | WriteDBLog.Success(name + "æ¾æç³è¯·", $"è¯»åæ¡æ¶ä¿¡æ¯ï¼\n车轮SNï¼{Wheel_id}\nè½®åIDï¼{Wheel_Type}\nè½¦è½®ç¶æï¼OK" + |
| | | $"\n读åæçå
çµä¿¡å·ï¼{PalletSignal}" + |
| | | $"\n\nåå
¥æ¡æ¶ä¿¡æ¯ï¼\n䏿ä½å·ï¼{area}\n第å 个车轮ï¼{(Stationinfo.quantity + 1)}\næçç±»åï¼1\nW_Enabl_Loadï¼true", "PCS"); |
| | | #endregion |
| | | return; |
| | | } |
| | | } |
| | |
| | | && x.tray_type == (wheel.e < 1100 ? "SmallTray" : "LargeTray") |
| | | && x.Number == mes_Detail.jobID |
| | | && x.heatNumber == mes_Detail.heatID).FirstOrDefault(); |
| | | if (Stationinfo == null) |
| | | Stationinfo = Stations.Where(x => x.enable && x.stationCode == NGStation && x.location_state == LocationStateEnum.Stroge.ToString() && x.quantity == 0).FirstOrDefault(); |
| | | if (Stationinfo != null) |
| | | { |
| | | #region æçç±»åä¸ä¸è´éæ´æ¢æç |
| | | if (Stationinfo.tray_type != (wheel.e < 1100 ? "SmallTray" : "LargeTray")) |
| | | { |
| | | Stationinfo.location_state = LocationStateEnum.Abnormal.ToString(); |
| | | Stationinfo.tray_type = Stationinfo.tray_type == "SmallTray" ? "SmallTray/LargeTray" : "LargeTray/SmallTray"; |
| | | Stationinfo.remark = "æçç±»åä¸ä¸è´éæ´æ¢æç"; |
| | | stationinfoRepository.Update(Stationinfo, true); |
| | | } |
| | | #endregion |
| | | var Pipelinedetails = plcRepository.Find(x => x.plcdetail_iotype == Pipelineplc.plcinfo_iotyep && x.plcdetail_number == Stationinfo.stationCode).ToList(); |
| | | var PalletSignal = (Int16)DBExtension.Read(Pipelinedetails.Where(x => x.plcdetail_name == "R_PalletSignal").First(), client);//读åæçä¿¡å·:1:æ,2æ |
| | | var PalletSignal = (Int16)DBExtension.Read(Pipelinedetails.Where(x => x.plcdetail_name == "R_PalletSignal").First(), Pipeline_client);//读åæçä¿¡å·:1:æ,2æ |
| | | if (PalletSignal == 1) |
| | | { |
| | | var SNS = Stationinfo.bindSN.Split(","); |
| | | List<string> list = new List<string>(); |
| | | foreach (var SN in SNS) |
| | | if (Stationinfo.bindSN != null) |
| | | { |
| | | if (!string.IsNullOrEmpty(SN)) |
| | | list.Add(SN); |
| | | foreach (var SN in SNS) |
| | | { |
| | | if (!string.IsNullOrEmpty(SN)) |
| | | list.Add(SN); |
| | | } |
| | | } |
| | | |
| | | //ç¼åæ¶ä¸è½¦è½®æ°éä¸SNå·æ°éä¸ä¸è´ |
| | | if (list.Count != Stationinfo.quantity) |
| | | { |
| | | Stationinfo.location_state = LocationStateEnum.Abnormal.ToString(); |
| | | Stationinfo.remark = "车轮æ°éä¸SNå·æ°éä¸ä¸è´"; |
| | | stationinfoRepository.Update(Stationinfo, true); |
| | | continue; |
| | | //åå
¥æ¡æ¶æ¥è¦ä¿¡å· |
| | | throw new Exception("䏿ä½è½¦è½®æ°éä¸SNå·æ°éä¸ä¸è´ï¼ä¸æä½ç¼å·ï¼" + Stationinfo.stationCode); |
| | | //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);//åºåè´§ä½å· |
| | | client.WriteByOrder("W_IndexNr", (Int16)(Stationinfo.quantity + 1), name);//æçä¸ç第å 个车轮 |
| | | client.WriteByOrder("W_Storage_Type", (Int16)1, name);//æçç±»å1-横æ¾;2-ç«æ¾(ææ¶åªææ¨ªæ¾æç) |
| | | client.WriteByOrder("W_Enabl_Load", true, name);//æ¯å¦å
许 |
| | | #region æ¥å¿è®°å½ |
| | | WriteDBLog.Success(name + "æ¾æç³è¯·", $"è¯»åæ¡æ¶ä¿¡æ¯ï¼\n车轮SNï¼{Wheel_id}\nè½®åIDï¼{Wheel_Type}\nè½¦è½®ç¶æï¼NG" + |
| | | $"\n读åæçå
çµä¿¡å·ï¼{PalletSignal}" + |
| | | $"\n\nåå
¥æ¡æ¶ä¿¡æ¯ï¼\n䏿ä½å·ï¼{area}\n第å 个车轮ï¼{(Stationinfo.quantity + 1)}\næçç±»åï¼1\nW_Enabl_Loadï¼true", "PCS"); |
| | | #endregion |
| | | return; |
| | | } |
| | | } |
| | |
| | | // StationCodes = new List<string>() { "X03001001", "X03001002" }; |
| | | |
| | | #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);//è´§ä½ç¶ææ´æ° |
| | | if (!finished && updatefinished) |
| | | client.WriteByOrder("W_Storage_update", false, name);//è´§ä½ç¶ææ´æ° |
| | | if (finished && !updatefinished) |
| | | { |
| | | var AreaNr = (Int16)DBExtension.Read(details.Where(x => x.plcdetail_name == "W_AreaNr").First(), client); |
| | | var station = stationinfoRepository.FindFirst(x => x.stationCode.Substring(x.stationCode.Length - 1, 1) == AreaNr.ToString()); |
| | | station.quantity = station.quantity++; |
| | | station.bindSN = station.bindSN == string.Empty ? Wheel_id : station.bindSN + "," + Wheel_id; |
| | | if (station.quantity == 0) |
| | | { |
| | | station.stationType = mes_Head.drawingNo; |
| | | station.Number = mes_Head.jobID; |
| | | station.heatNumber = mes_Detail.heatID; |
| | | } |
| | | var count = stationinfoRepository.Update(station); |
| | | if (count < 1) |
| | | throw new Exception($"䏿ä½ä¿¡æ¯æ´æ°å¤±è´¥ï¼ä¸æä½ç¼å·ï¼{station.stationCode}"); |
| | | client.WriteByOrder("W_Storage_update", true, name);//è´§ä½ç¶ææ´æ° |
| | | client.WriteByOrder("W_Enabl_Load", false, name);//æ¯å¦å
许 |
| | | } |
| | | |
| | | #region |
| | | //for (int i = 0; i < StationCodes.Count - 1; i++) |
| | | //{ |