protected bool UploadMesdetailData(LOCAL_MES_STEP_INFO_DETAILModel m) { //if (mesDA.MesDetailExist(m.RECID)) //{ // m.RECID = System.Guid.NewGuid().ToString(); //} FT_MES_STEP_INFO_DETAILModel ftM = new FT_MES_STEP_INFO_DETAILModel(); ftM.DATA_NAME = m.DATA_NAME; ftM.DATA_VALUE = m.DATA_VALUE; ftM.LAST_MODIFY_TIME = m.LAST_MODIFY_TIME; ftM.RECID = m.RECID; ftM.SERIAL_NUMBER = m.SERIAL_NUMBER; ftM.STATUS = m.STATUS; ftM.STEP_NUMBER = m.STEP_NUMBER; ftM.TRX_TIME = m.TRX_TIME; try { int reTryMax = 10; int reTryCounter = 0; while (!mesDA.AddMesDetailinfo(ftM)) { Thread.Sleep(1000); reTryCounter++; if (reTryCounter > reTryMax) { logRecorder.AddDebugLog(this.nodeName, string.Format("上传详细数据到MES失败,条码:{0},工位:{1}", ftM.SERIAL_NUMBER, ftM.STEP_NUMBER)); return(false); } } logRecorder.AddDebugLog(this.nodeName, string.Format("上传详细数据到MES成功,条码:{0},工位:{1}", ftM.SERIAL_NUMBER, ftM.STEP_NUMBER)); return(true); } catch (Exception ex) { logRecorder.AddDebugLog(this.nodeName, string.Format("上传详细数据失败,MES数据库访问异常,条码:{0},工位:{1},{2}", ftM.SERIAL_NUMBER, ftM.STEP_NUMBER, ex.Message)); return(false); } }
//private void MesUploadProc() //{ // try // { // //按照MES工艺路线要求,又考虑到实际工位布局顺序跟MES工艺路线并不一致,确定如下上传顺序: // //气密2-零秒点火-气密1,3->一次试火->二次试火->外观检测->包装下线 // //MES工位顺序:RQ-ZA041->RQ-ZA030->RQ-ZA040->RQ-ZA050,RQ-ZA051,RQ-ZA052,RQ-ZA053->RQ-ZA060->RQ-ZA070->RQ-ZA080 // //1 先传RQ-ZA041 // string[] mesProcessSeq = new string[] { "RQ-ZA041", "RQ-ZA030", "RQ-ZA040", "RQ-ZA050", "RQ-ZA051", "RQ-ZA052", "RQ-ZA053", "RQ-ZA060", "RQ-ZA070"}; // string[] fireTryA = new string[]{ "RQ-ZA050", "RQ-ZA051", "RQ-ZA052", "RQ-ZA053"}; // List<string> strConditions = new List<string>(); // for(int i=0;i<mesProcessSeq.Count();i++) // { // strConditions.Add(string.Format("UPLOAD_FLAG = 0 and STEP_NUMBER='{0}' order by TRX_TIME asc",mesProcessSeq[i])); // } // for(int i=0;i<strConditions.Count;i++) // { // string strWhere = strConditions[i]; // List<LOCAL_MES_STEP_INFOModel> models = localMesBasebll.GetModelList(strWhere); // if(models == null || models.Count()<1) // { // continue; // } // if(0==i) // { // foreach (LOCAL_MES_STEP_INFOModel m in models) // { // UploadMesbasicData(m); // } // } // else // { // foreach (LOCAL_MES_STEP_INFOModel m in models) // { // //检测上道工艺是否上传完成 // string strCheckWhere = ""; // if ("RQ-ZA040" == mesProcessSeq[i]) //气密1,3 // { // //要求气密1,3都检测完一起上传 // string strCond1 = string.Format("UPLOAD_FLAG=0 and SERIAL_NUMBER='{0}' and AutoStationName='气密检查1'", m.SERIAL_NUMBER); // string strCond2 = string.Format("UPLOAD_FLAG=0 and SERIAL_NUMBER='{0}' and AutoStationName='气密检查3'", m.SERIAL_NUMBER); // if((!localMesBasebll.ExistByCondition(strCond1)) || (!localMesBasebll.ExistByCondition(strCond2))) // { // continue; // } // strCheckWhere = string.Format("UPLOAD_FLAG = 1 and STEP_NUMBER='{0}' and SERIAL_NUMBER='{1}' order by TRX_TIME asc", mesProcessSeq[i - 1], m.SERIAL_NUMBER); // } // else if (fireTryA.Contains(mesProcessSeq[i])) //一次试火 // { // strCheckWhere = string.Format("UPLOAD_FLAG = 1 and STEP_NUMBER='{0}' and SERIAL_NUMBER='{1}' order by TRX_TIME asc", "RQ-ZA040", m.SERIAL_NUMBER); // } // else if ("RQ-ZA060"==mesProcessSeq[i]) //二次试火 // { // strCheckWhere = string.Format("UPLOAD_FLAG = 1 and (STEP_NUMBER='RQ-ZA050' or STEP_NUMBER='RQ-ZA051' or STEP_NUMBER='RQ-ZA052' or STEP_NUMBER='RQ-ZA053') and SERIAL_NUMBER='{0}' order by TRX_TIME asc", m.SERIAL_NUMBER); // } // else // { // strCheckWhere = string.Format("UPLOAD_FLAG = 1 and STEP_NUMBER='{0}' and SERIAL_NUMBER='{1}' order by TRX_TIME asc", mesProcessSeq[i-1],m.SERIAL_NUMBER); // } // // List<LOCAL_MES_STEP_INFOModel> preuploadModels = localMesBasebll.GetModelList(strCheckWhere); // if (localMesBasebll.ExistByCondition(strCheckWhere)) // { // UploadMesbasicData(m); // } // else // { // continue; // } // } // } // } // //logRecorder.AddDebugLog(this.objectName,"MES 数据上传测试!"); // for (int i = 0; i < strConditions.Count; i++) // { // string strWhere = strConditions[i]; // List<LOCAL_MES_STEP_INFO_DETAILModel> models = localMesDetailbll.GetModelList(strWhere); // if (models == null || models.Count() < 1) // { // continue; // } // if (0==i) // { // foreach (LOCAL_MES_STEP_INFO_DETAILModel m in models) // { // UploadMesdetailData(m); // } // } // else // { // foreach (LOCAL_MES_STEP_INFO_DETAILModel m in models) // { // //检测上道工艺是否上传完成 // string strCheckWhere = ""; // if ("RQ-ZA040" == mesProcessSeq[i]) //气密1,3 // { // //要求气密1,3都检测完一起上传 // string strCond1 = string.Format("UPLOAD_FLAG=0 and SERIAL_NUMBER='{0}' and AutoStationName='气密检查1'", m.SERIAL_NUMBER); // string strCond2 = string.Format("UPLOAD_FLAG=0 and SERIAL_NUMBER='{0}' and AutoStationName='气密检查3'", m.SERIAL_NUMBER); // if(!localMesDetailbll.ExistByCondition(strCond1) || (!localMesDetailbll.ExistByCondition(strCond2))) // { // continue; // } // } // else if (fireTryA.Contains(mesProcessSeq[i])) // { // strCheckWhere = string.Format("UPLOAD_FLAG = 1 and STEP_NUMBER='{0}' and SERIAL_NUMBER='{1}' order by TRX_TIME asc", "RQ-ZA040", m.SERIAL_NUMBER); // } // else if (mesProcessSeq[i] == "RQ-ZA060") // { // strCheckWhere = string.Format("UPLOAD_FLAG = 1 and (STEP_NUMBER='RQ-ZA050' or STEP_NUMBER='RQ-ZA051' or STEP_NUMBER='RQ-ZA052' or STEP_NUMBER='RQ-ZA053') and SERIAL_NUMBER='{0}' order by TRX_TIME asc", m.SERIAL_NUMBER); // } // else // { // strCheckWhere = string.Format("UPLOAD_FLAG = 1 and STEP_NUMBER='{0}' and SERIAL_NUMBER='{1}' order by TRX_TIME asc", mesProcessSeq[i - 1], m.SERIAL_NUMBER); // } // if (localMesDetailbll.ExistByCondition(strCheckWhere)) // { // UploadMesdetailData(m); // } // else // { // continue; // } // } // } // } // } // catch (Exception ex) // { // logRecorder.AddLog(new LogModel(objectName, ex.ToString(), EnumLoglevel.错误)); // } //} //private void UploadMesbasicData(LOCAL_MES_STEP_INFOModel m) //{ // if (mesDA.MesBaseExist(m.RECID)) // { // m.UPLOAD_FLAG = true; // localMesBasebll.Update(m); // return; // } // FT_MES_STEP_INFOModel ftM = new FT_MES_STEP_INFOModel(); // ftM.CHECK_RESULT = m.CHECK_RESULT; // ftM.DEFECT_CODES = m.DEFECT_CODES; // ftM.LAST_MODIFY_TIME = System.DateTime.Now; //m.LAST_MODIFY_TIME; // ftM.REASON = m.REASON; // ftM.RECID = m.RECID; // ftM.SERIAL_NUMBER = m.SERIAL_NUMBER; // ftM.STATUS = m.STATUS; // ftM.STEP_MARK = m.STEP_MARK; // ftM.STEP_NUMBER = m.STEP_NUMBER; // ftM.TRX_TIME = System.DateTime.Now;//m.TRX_TIME; // ftM.USER_NAME = m.USER_NAME; // mesDA.AddMesBaseinfo(ftM); // logRecorder.AddDebugLog(objectName, string.Format("上传基本数据到MES成功,条码:{0},工位:{1}", ftM.SERIAL_NUMBER, ftM.STEP_NUMBER)); // m.UPLOAD_FLAG = true; // localMesBasebll.Update(m); //} private void UploadMesdetailData(LOCAL_MES_STEP_INFO_DETAILModel m) { if (mesDA.MesDetailExist(m.RECID)) { m.UPLOAD_FLAG = true; localMesDetailbll.Update(m); return; } FT_MES_STEP_INFO_DETAILModel ftM = new FT_MES_STEP_INFO_DETAILModel(); ftM.DATA_NAME = m.DATA_NAME; ftM.DATA_VALUE = m.DATA_VALUE; ftM.LAST_MODIFY_TIME = System.DateTime.Now; //m.LAST_MODIFY_TIME; ftM.RECID = m.RECID; ftM.SERIAL_NUMBER = m.SERIAL_NUMBER; ftM.STATUS = m.STATUS; ftM.STEP_NUMBER = m.STEP_NUMBER; ftM.TRX_TIME = System.DateTime.Now;// m.TRX_TIME; mesDA.AddMesDetailinfo(ftM); logRecorder.AddDebugLog(objectName, string.Format("上传详细数据到MES成功,条码:{0},工位:{1}", ftM.SERIAL_NUMBER, ftM.STEP_NUMBER)); m.UPLOAD_FLAG = true; localMesDetailbll.Update(m); }