Beispiel #1
0
        //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);
        }
Beispiel #2
0
        protected bool AsyUploadMesdata(string productBarcode, string[] mesProcessSeq, ref string reStr)
        {
            try
            {
                // int uploadDelay = 2000;//上传延迟5秒
                List <string> strConditions = new List <string>();
                for (int i = 0; i < mesProcessSeq.Count(); i++)
                {
                    strConditions.Add(string.Format("SERIAL_NUMBER='{0}' and UPLOAD_FLAG = 0 and STEP_NUMBER='{1}' order by TRX_TIME asc", productBarcode, mesProcessSeq[i]));
                    string strWhere = strConditions[i];
                    List <LOCAL_MES_STEP_INFOModel> models = localMesBasebll.GetModelList(strWhere);
                    if (models == null || models.Count() < 1)
                    {
                        continue;
                    }
                    string process = mesProcessSeq[i];
                    if (process == "RQ-ZA240")
                    {
                        if (models.Count() > 1)
                        {
                            LOCAL_MES_STEP_INFOModel model1  = models[0];
                            LOCAL_MES_STEP_INFOModel model2  = models[1];
                            LOCAL_MES_STEP_INFOModel uploadM = model1.Clone() as LOCAL_MES_STEP_INFOModel;

                            if (model1.CHECK_RESULT == 1 || model2.CHECK_RESULT == 1)
                            {
                                uploadM.CHECK_RESULT = 1;
                                if (model1.CHECK_RESULT == 1 && model2.CHECK_RESULT == 1)
                                {
                                    uploadM.DEFECT_CODES += (";" + model2.DEFECT_CODES);
                                }
                                else if (model2.CHECK_RESULT == 1)
                                {
                                    uploadM.DEFECT_CODES = model2.DEFECT_CODES;
                                }
                            }

                            if (!UploadMesbasicData(uploadM))
                            {
                                return(false);
                            }

                            model1.UPLOAD_FLAG = true;
                            model2.UPLOAD_FLAG = true;
                            localMesBasebll.Update(model1);
                            localMesBasebll.Update(model2);
                            //Thread.Sleep(uploadDelay);
                        }
                        else if (models.Count() == 1)
                        {
                            if (!UploadMesbasicData(models[0]))
                            {
                                return(false);
                            }
                            models[0].UPLOAD_FLAG = true;
                            localMesBasebll.Update(models[0]);
                            // Thread.Sleep(uploadDelay);
                        }
                    }
                    else
                    {
                        foreach (LOCAL_MES_STEP_INFOModel m in models)
                        {
                            if (!UploadMesbasicData(m))
                            {
                                return(false);
                            }
                            m.UPLOAD_FLAG = true;
                            localMesBasebll.Update(m);
                            // Thread.Sleep(uploadDelay);
                        }
                    }
                }
                //for (int i = 0; i < strConditions.Count; i++)
                //{


                //}
                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;
                    }
                    string process = mesProcessSeq[i];
                    if (process == "RQ-ZA240")
                    {
                        if (models.Count() > 1)
                        {
                            LOCAL_MES_STEP_INFO_DETAILModel model1  = models[0];
                            LOCAL_MES_STEP_INFO_DETAILModel model2  = models[1];
                            LOCAL_MES_STEP_INFO_DETAILModel uploadM = model1.Clone() as LOCAL_MES_STEP_INFO_DETAILModel;
                            uploadM.DATA_VALUE += (";" + model2.DATA_VALUE);
                            if (!UploadMesdetailData(uploadM))
                            {
                                return(false);
                            }
                            model1.UPLOAD_FLAG = true;
                            model2.UPLOAD_FLAG = true;
                            localMesDetailbll.Update(model1);
                            localMesDetailbll.Update(model2);
                            //  Thread.Sleep(uploadDelay);
                        }
                        else if (models.Count() == 1)
                        {
                            if (!UploadMesdetailData(models[0]))
                            {
                                return(false);
                            }
                            models[0].UPLOAD_FLAG = true;
                            localMesDetailbll.Update(models[0]);
                            // Thread.Sleep(uploadDelay);
                        }
                    }
                    else
                    {
                        foreach (LOCAL_MES_STEP_INFO_DETAILModel m in models)
                        {
                            if (!UploadMesdetailData(m))
                            {
                                return(false);
                            }
                            m.UPLOAD_FLAG = true;
                            localMesDetailbll.Update(m);
                            // Thread.Sleep(uploadDelay);
                        }
                    }
                }
                return(true);
            }
            catch (Exception ex)
            {
                reStr = ex.ToString();
                this.ThrowErrorStat(ex.ToString(), EnumNodeStatus.设备故障);
                return(false);
            }
        }