using System; using System.Collections.Generic; using System.Data; using MesDataFunction; using MesServerWork; using MisDataFunDll; using MisDataSaveDate; using Newtonsoft.Json.Linq; namespace MesServerFunctions { partial class FunctionMES { /// /// 正常逻辑工作(传递机型) /// /// /// 1 /// /// /// private void EngineTypeGetOver_PLC_Work(string OpName, int EngineTypeID, string EngineType, string EngineID, int PartPallet_Code,string OrderForm) { int IsAllowWork; int RepairPartStatusPLC = 0; //第一步,将操作指南转移到操作指南_临时表中 MisDataFun.MesServer_ProcessList_EngineTypeOver(OpName); //第二步,将零件信息转移到零件_临时表中 MisDataFun.MesServer_Process_EngineTypeOver(OpName); //通知web显示 SendMessageFun.SendMessage("5123", "1111", OpName); MIS_BASE.Read_RepairStatus_PLC(OpName, out RepairPartStatusPLC);//返修标志 // 通知web返修标志 SendMessageFun.SendInfomation("RepairPartStatusPLC", Convert.ToString(RepairPartStatusPLC), OpName);//显示返修标志 //第四步,获取是否允许工作 MisDataFun.MesServer_Judge_IsCanWork(OpName, out IsAllowWork); string IsMatchBarcode = "1"; // 第五步 150工位需要验证模组码才能放行 if (MisDataFun.GetSpecialOpExist(OpName, "到站扫托盘码")) { //第五步 判断是否需要二次扫码验证Pack码 MIS_BASE.Read_TagValueByTagTypeID(54, OpName, out IsMatchBarcode); if (IsMatchBarcode != "1") { if(MisDataFun.GetSpecialOpExist(OpName, "模组码打印工位")) // 模组打印工位才调用打印机打印模组码 { PrinterCommandCenter.PrintToPrinter(OpName, EngineID); } SendMessageFun.AsyncSendMessage_Notice(OpName, "请扫描二维码进行托盘校验!","条码扫描"); } } if (MisDataFun.GetSpecialOpExist(OpName, "客户标签验证工位")) { string clientTag = MisDataFun.GetMesClientTagValue(OpName,EngineID,EngineTypeID); if(clientTag.Length > 40) { MIS_BASE.Write_TagValueByTagTypeID(116, OpName, clientTag.Substring(0,38)); // 前40位 MIS_BASE.Write_TagValueByTagTypeID(117, OpName, clientTag.Substring(38)); // 40位后 } else MIS_BASE.Write_TagValueByTagTypeID(116, OpName, clientTag); // 前40位 } if (MisDataFun.GetSpecialOpExist(OpName, "模组码校验工位")) // 传递模组打印内容 让视觉进行比对 { DataTable ModelDataDt = MisDataFun.GetMesModelPrintData(OpName,EngineID); if(ModelDataDt.Rows.Count > 0) { string leftTop = ModelDataDt.Rows[0]["LeftTop"].ToString(); string rightTop = ModelDataDt.Rows[0]["RightTop"].ToString(); string leftBottom = ModelDataDt.Rows[0]["LeftBottom"].ToString(); MIS_BASE.Write_TagValueByTagTypeID(116, OpName, leftTop); MIS_BASE.Write_TagValueByTagTypeID(117, OpName, leftBottom); MIS_BASE.Write_TagValueByTagTypeID(121, OpName, rightTop); } } //暂时先定义为扫描完成才能进行压装工作,因为考虑到工作完成后,操作工未必会去扫描物料的情况 if (IsAllowWork == 1 && IsMatchBarcode == "1") { //通知PLC允许工作,允许工作在保存完成时清空 MIS_BASE.Write_FixAllow(OpName, true); } else { string msg = "请扫描物料!"; if (IsMatchBarcode != "1") msg = "请扫码进行托盘比对!"; SendMessageFun.AsyncSendMessage_Notice(OpName, msg); MisDataFun.LogRecording_OP(OpName, "INFO", "barcode", msg); } } /// /// 二次工作 /// /// private void EngineTypeGetOver_PLC_Work_two(string OpName) { MisDataFun.LogRecording_OP(OpName, "INFO", "MIS", "PLC传递机型!"); MIS_BASE.Write_TagValueByTagTypeID(34, OpName, false); // 复位报警(MES) int EngineTypeID;//机型代码 string EngineType;//机型 string EngineID;//工件编号 string OrderForm; // 工单号 int PartPallet_Code;//托盘编号 MIS_BASE.GetEngineTypeFromPLC(OpName, out EngineTypeID, out EngineType, out EngineID, out PartPallet_Code, out OrderForm); // 判断PLC机型是否写入 if (EngineTypeID <= 0 || EngineID == "") { MIS_BASE.Write_TagValueByTagTypeID(34, OpName, true);// MES报警 string msg = "【" + OpName + "】" + "PLC机型写入为空,EngineTypeID:" + EngineTypeID + ",EngineID:" + EngineID; SendMessage.AsyncSendMessage_Notice(OpName, msg); MisDataFun.LogRecording_OP(OpName, "ERROR", "EngineTypeGetOver", msg); return; } // PDC产线plc只写了发动机号和机型代码,其余要从数据库中读取 MisDataFun.Moby_Select_PDC(EngineID, out OrderForm, out EngineType, out EngineTypeID); MisDataFun.OpName_MIS_MOBY_Insert(OpName, EngineTypeID, EngineType, EngineID, PartPallet_Code, OrderForm, 0, 0, ""); EngineTypeGetOver_PLC_Work(OpName, EngineTypeID, EngineType, EngineID, PartPallet_Code, OrderForm); } /// /// 跳过二次工作 /// /// private void EngineTypeGetOver_PLC_Work_Skip(string OpName) { MIS_BASE.Write_MesWorkFinish(OpName, true); } /// /// 返修件需要工作 /// /// 工位号 private void IsNeedRepaire_OK(string OpName) { //string orderForm = ""; //int engineTypeID; //string engineType = ""; //string engineID = ""; //string palletCode = ""; //int isRepair; //string repairCode = ""; ////从监控系统中查询出本工位信息 //BaseDataSystemMES.OpName_MIS_Moby_Select(OpName, //out orderForm, out engineTypeID, out engineType, //out engineID, out palletCode, out isRepair, out repairCode); //EngineTypeGetOver_PLC_Work(OpName, engineTypeID, engineType, engineID, Convert.ToInt32(palletCode),orderForm); } } }