/// <summary>
        /// 序列号转换采集,只支持分板,不支持合板
        /// </summary>
        /// <param name="domainDataProvider"></param>
        /// <param name="iD"></param>
        /// <param name="actionType"></param>
        /// <param name="resourceCode"></param>
        /// <param name="userCode"></param>
        /// <param name="product"></param>
        /// <param name="datas1">转换后的ID组</param>
        /// <param name="datas2">NULL</param>
        /// <returns></returns>
        public Messages Execute(ActionEventArgs actionEventArgs)
        {
            // Added by Icyer 2006/10/08
            if (((SplitIDActionEventArgs)actionEventArgs).IsUndo == true)
            {
                return(this.UndoExecute((SplitIDActionEventArgs)actionEventArgs));
            }
            // Added end

            Messages         messages         = new Messages();
            DataCollectDebug dataCollectDebug = new DataCollectDebug(this.GetType().ToString() + "Collect");

            dataCollectDebug.WhenFunctionIn(messages);
            try
            {
                if (((SplitIDActionEventArgs)actionEventArgs).SplitedIDs == null || ((SplitIDActionEventArgs)actionEventArgs).SplitedIDs.Length == 0)
                {
                    throw new Exception("$CS_System_Params_Losted");
                }

                ActionOnLineHelper helper            = new ActionOnLineHelper(this.DataProvider);
                DataCollectFacade  dataCollectFacade = new DataCollectFacade(this.DataProvider);

                //laura:  GetLastSimulation into NowSimulation
                string sourcCard = actionEventArgs.ProductInfo.LastSimulation.RunningCard.ToUpper();

                //GetLastSimulation 是获取当前open工单中的一笔,GetSimulation 是获取所有simulation中mdate 最晚的一笔。
                Simulation objSimulation = dataCollectFacade.GetSimulation(sourcCard) as Simulation;
                if (objSimulation == null)
                {
                    throw new Exception("rcard in simulation not existed!");
                }
                actionEventArgs.ProductInfo.NowSimulation = objSimulation;

                //laura:  GetLastSimulationReport into NowSimulationReport
                SimulationReport objSimulationReport = dataCollectFacade.GetLastSimulationReport(sourcCard) as SimulationReport;
                if (objSimulationReport == null)
                {
                    throw new Exception("rcard in simulationreport not existed!");
                }
                actionEventArgs.ProductInfo.NowSimulationReport = objSimulationReport;

                //laura:  如果需要,补充 ProductInfo 信息
                //to-do...

                //
                actionEventArgs.ProductInfo.NowSimulation.IDMergeRule           = 1; //actionEventArgs.ProductInfo.NowSimulation.IDMergeRule/((SplitIDActionEventArgs)actionEventArgs).SplitedIDs.Length;
                actionEventArgs.ProductInfo.NowSimulation.TranslateCard         = actionEventArgs.ProductInfo.LastSimulation.RunningCard;
                actionEventArgs.ProductInfo.NowSimulation.TranslateCardSequence = actionEventArgs.ProductInfo.LastSimulation.RunningCardSequence;
                actionEventArgs.ProductInfo.NowSimulation.NGTimes = actionEventArgs.ProductInfo.LastSimulation.NGTimes;

                for (int i = 0; i < ((SplitIDActionEventArgs)actionEventArgs).SplitedIDs.Length; i++)
                {
                    //修改SIMULATION
                    //Laws Lu,2005/08/15,新增	完工逻辑,在其他Check都通过的情况下,所有的RunningCard应该是GOOD状态
                    //暂时不考虑线外工序
                    if (actionEventArgs.ProductInfo.NowSimulation.RouteCode != "" && dataCollectFacade.OPIsMORouteLastOP(
                            actionEventArgs.ProductInfo.NowSimulation.MOCode
                            , actionEventArgs.ProductInfo.NowSimulation.RouteCode
                            , actionEventArgs.ProductInfo.NowSimulation.OPCode))
                    {
                        actionEventArgs.ProductInfo.NowSimulation.IsComplete  = "1";
                        actionEventArgs.ProductInfo.NowSimulation.EAttribute1 = "GOOD";
                    }
                    //End Laws Lu
                    actionEventArgs.ProductInfo.NowSimulation.RunningCard = ((SplitIDActionEventArgs)actionEventArgs).SplitedIDs[i].ToString();
                    /* added by jessie lee,如果是 序列号转换 */
                    if (string.Compare((actionEventArgs as SplitIDActionEventArgs).IDMergeType, IDMergeType.IDMERGETYPE_IDMERGE, true) == 0)
                    {
                        /* 转换到同一张工单 */
                        if ((actionEventArgs as SplitIDActionEventArgs).UpdateSimulation)
                        {
                            actionEventArgs.ProductInfo.NowSimulation.RunningCardSequence
                                = (actionEventArgs as SplitIDActionEventArgs).ExistIMEISeq + 10;
                        }
                        else
                        {
                            actionEventArgs.ProductInfo.NowSimulation.RunningCardSequence = ActionOnLineHelper.StartSeq;
                        }
                    }
                    else
                    {
                        /* 不是 序列号转换 */
                        actionEventArgs.ProductInfo.NowSimulation.RunningCardSequence = ActionOnLineHelper.StartSeq;
                    }
                    actionEventArgs.ProductInfo.NowSimulation.MOSeq = actionEventArgs.ProductInfo.LastSimulation.MOSeq;     // Added by Icyer 2007/07/03

                    //messages.AddMessages(helper.Execute(actionEventArgs));
                    //messages.AddMessages(helper.Execute(actionEventArgs, true,false));  //线外工序,不用 insert tblonwip。

                    if (messages.IsSuccess())
                    {
                        //#region 将ID添加到MO2RCARDLINK范围表内
                        DBDateTime dbDateTime = FormatHelper.GetNowDBDateTime(this.DataProvider);
                        //MOFacade _MOFacade = new MOFacade(this.DataProvider);
                        //MO2RCARDLINK mo2cardlink = new MO2RCARDLINK();
                        //mo2cardlink.MOCode = actionEventArgs.ProductInfo.NowSimulation.MOCode;
                        //mo2cardlink.RCard = ((SplitIDActionEventArgs)actionEventArgs).SplitedIDs[i].ToString().Trim().ToUpper();
                        //mo2cardlink.MDate = dbDateTime.DBDate;
                        //mo2cardlink.MUser = actionEventArgs.UserCode;
                        //mo2cardlink.MTime = dbDateTime.DBTime;
                        //mo2cardlink.PrintTimes = 0;
                        //mo2cardlink.LastPrintUSER = "";
                        //mo2cardlink.LastPrintDate = 0;
                        //mo2cardlink.LastPrintTime = 0;
                        //_MOFacade.AddMO2RCardLink(mo2cardlink);
                        //#endregion

                        #region 将ID添加到SplitBoard
                        SplitBoard splitBorad = new SplitBoard();
                        splitBorad.Seq           = actionEventArgs.ProductInfo.NowSimulation.RunningCardSequence;
                        splitBorad.Mocode        = actionEventArgs.ProductInfo.NowSimulation.MOCode;
                        splitBorad.Rcard         = ((SplitIDActionEventArgs)actionEventArgs).SplitedIDs[i].ToString().Trim().ToUpper();
                        splitBorad.Modelcode     = actionEventArgs.ProductInfo.NowSimulation.ModelCode;
                        splitBorad.Itemcode      = actionEventArgs.ProductInfo.NowSimulation.ItemCode;
                        splitBorad.Opcode        = actionEventArgs.ProductInfo.NowSimulation.OPCode;
                        splitBorad.Rescode       = actionEventArgs.ResourceCode;
                        splitBorad.Routecode     = actionEventArgs.ProductInfo.NowSimulation.RouteCode;
                        splitBorad.Scard         = actionEventArgs.ProductInfo.NowSimulation.SourceCard;
                        splitBorad.Segcode       = actionEventArgs.ProductInfo.NowSimulationReport.SegmentCode;
                        splitBorad.Shiftcode     = actionEventArgs.ProductInfo.NowSimulationReport.ShiftCode;
                        splitBorad.Shifttypecode = actionEventArgs.ProductInfo.NowSimulationReport.ShiftTypeCode;
                        splitBorad.Sscode        = actionEventArgs.ProductInfo.NowSimulationReport.StepSequenceCode;
                        splitBorad.Tpcode        = actionEventArgs.ProductInfo.NowSimulationReport.TimePeriodCode;
                        splitBorad.Muser         = actionEventArgs.UserCode;
                        splitBorad.Mdate         = dbDateTime.DBDate;
                        splitBorad.Mtime         = dbDateTime.DBTime;
                        dataCollectFacade.AddSplitBoard(splitBorad);
                        #endregion
                    }
                }
                //}
            }
            catch (Exception e)
            {
                messages.Add(new Message(e));
            }
            dataCollectDebug.WhenFunctionOut(messages);
            return(messages);
        }
Example #2
0
        private void ucBtnOK_Click(object sender, System.EventArgs e)
        {
            if (this.ucLERunningCard.Value.Trim() == string.Empty)
            {
                //Laws Lu,2005/08/11,新增焦点设置
                ucLERunningCard.TextFocus(true, true);
                return;
            }

            this.ucMessage.Add(string.Format("<< {0}", this.ucLERunningCard.Value.Trim().ToUpper()));

            // 输入分板前产品序列号
            if (this._currSequence == 0)
            {
                #region 工单、序列号匹配
                _runningCardList = new ArrayList();

                if (this.txtMoCode.Checked)
                {
                    if (string.IsNullOrEmpty(txtMoCode.Value.ToUpper().Trim()))
                    {
                        this.ucMessage.Add(new UserControl.Message(MessageType.Error, "$CS_Please_Input_MOCode"));
                        this.ucLERunningCard.Value = "";

                        //Laws Lu,2005/08/11,新增焦点设置
                        txtMoCode.Focus();
                        return;
                    }
                }

                //Laws Lu,2005/10/19,新增	缓解性能问题
                //Laws Lu,2006/12/25 修改	减少Open/Close的次数
                ((BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider)DataProvider).PersistBroker.CloseConnection();
                ((BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider)DataProvider).PersistBroker.AutoCloseConnection = true;
                //added by jessie lee, 2005/11/29
                #region 判断转换前序列号是否符合条件
                //长度检查
                if (bCardTransLenULE.Checked)
                {
                    if (bCardTransLenULE.Value.Trim().Length == 0)
                    {
                        this.ucMessage.Add(new UserControl.Message(MessageType.Error, "$CS_Before_Card_Transfer_Empty"));
                        ucLERunningCard.TextFocus(true, true);
                        return;
                    }

                    int len = 0;
                    try
                    {
                        len = int.Parse(bCardTransLenULE.Value.Trim());
                    }
                    catch
                    {
                        this.ucMessage.Add(new UserControl.Message(MessageType.Error, "$Error_BeforeCardTransLen_Should_be_Integer"));
                        ucLERunningCard.TextFocus(true, true);
                        return;
                    }

                    if (len != this.ucLERunningCard.Value.Trim().Length)
                    {
                        this.ucMessage.Add(new UserControl.Message(MessageType.Error, "$Error_BeforeCardTransLen_Not_Correct"));
                        ucLERunningCard.TextFocus(true, true);
                        return;
                    }
                }

                //首字符串检查
                if (bCardTransLetterULE.Checked)
                {
                    if (bCardTransLetterULE.Value.Trim().Length == 0)
                    {
                        this.ucMessage.Add(new UserControl.Message(MessageType.Error, "$CS_Before_Card_Transfer_FLetter_Empty"));
                        ucLERunningCard.TextFocus(true, true);
                        return;
                    }

                    int index = ucLERunningCard.Value.Trim().IndexOf(bCardTransLetterULE.Value.Trim());
                    if (index != 0)
                    {
                        this.ucMessage.Add(new UserControl.Message(MessageType.Error, "$CS_Before_Card_Transfer_FLetter_NotCompare"));
                        ucLERunningCard.TextFocus(true, true);
                        return;
                    }
                }
                #endregion

                #region 取得分板比例,从工单和SMT是否是打叉板得到分板比例,若不是,带出工单的分版比例

                simReport = _DataCollectFacade.GetLastSimulationReport(this.ucLERunningCard.Value.Trim().ToUpper());
                if (simReport == null)
                {
                    this.ucMessage.Add(new UserControl.Message(MessageType.Error, "$Error_CS_ID_Not_Exist"));
                    this.ucLERunningCard.Value = "";
                    this.ucLERunningCard.TextFocus(true, true);
                    return;
                }
                else
                {
                    if (simReport.IsComplete != "1")
                    {
                        //完工后才可以分板,故注释。
                        //主要应用于以下业务情况:
                        //序列号 s1 通过两张工单 mo1, mo2 完成。s1 经过第一张工单 mo1 完工后,需要进行分板 s1--> s1-1, s1-2,
                        //分板后再用 s1-1, s1-2 进行第二张工单 mo2 的归属生产。
                        this.ucMessage.Add(new UserControl.Message(MessageType.Error, "$CS_ERROR_PRODUCT_NO_COMPLETE"));
                        ucLERunningCard.TextFocus(true, true);
                        return;
                    }

                    if (txtMoCode.Checked)
                    {
                        if (string.Compare(txtMoCode.Value.ToUpper().Trim(), simReport.MOCode, true) != 0)
                        {
                            this.ucMessage.Add(new UserControl.Message(MessageType.Error, "$RCARD_NOT_IN_MO"));
                            ucLERunningCard.TextFocus(true, true);
                            return;
                        }
                    }

                    int rcardCount = _DataCollectFacade.GetSplitBoardCount(this.ucLERunningCard.Value.Trim().ToUpper());

                    if (rcardCount > 0)
                    {
                        //已经分板的序列号就不可以在分了
                        this.ucMessage.Add(new UserControl.Message(MessageType.Error, "$CS_ERROR_PRODUCT_ALREADY_SPLITE"));
                        ucLERunningCard.TextFocus(true, true);
                        return;
                    }
                }


                SMTFacade smtFacade = new SMTFacade(this.DataProvider);
                object    objsmtrel = smtFacade.GetSMTRelationQty(this.ucLERunningCard.Value.Trim().ToUpper(), simReport.MOCode);
                if (objsmtrel != null)
                {
                    Smtrelationqty smtrel = (Smtrelationqty)objsmtrel;
                    this.txtIDMergeValue.Text = Convert.ToString(smtrel.Relationqtry);
                }
                else
                {
                    MOFacade mofacade = new MOFacade(this.DataProvider);
                    object   objMO    = mofacade.GetMO(simReport.MOCode);
                    if (objMO != null)
                    {
                        MO mo = (MO)objMO;
                        this.txtIDMergeValue.Text = Convert.ToString(mo.IDMergeRule);
                    }
                    else
                    {
                        this.ucMessage.Add(new UserControl.Message(MessageType.Error, "$CS_MO_Not_Exit"));
                        txtMoCode.Focus();
                        txtMoCode.SelectAll();
                        return;
                    }
                }
                #endregion

                #region 判断分板前序列号是否存在


                int mergeRule = 1;
                try
                {
                    mergeRule = System.Int32.Parse(this.txtIDMergeValue.Text.ToUpper().Trim());
                }
                catch
                {
                    this.ucMessage.Add(new UserControl.Message(MessageType.Error, "$Error_CS_IDMerge_Should_be_Integer"));//分板比例必须为整数
                    //Laws Lu,2005/08/11,新增焦点设置
                    ucLERunningCard.TextFocus(true, true);
                    return;
                }

                if (mergeRule <= 0)
                {
                    this.ucMessage.Add(new UserControl.Message(MessageType.Error, "$Error_CS_IDMerge_Should_Over_Zero"));//分板比例必须大于零
                    ucLERunningCard.TextFocus(true, true);
                    return;
                }
                this._mergeRule = mergeRule;
                #endregion

                #endregion
            }
            else
            {
                //added by jessie lee, 2005/11/29
                #region 判断转换后序列号是否符合条件
                //长度检查
                if (aCardTransLenULE.Checked)
                {
                    if (aCardTransLenULE.Value.Trim().Length == 0)
                    {
                        this.ucMessage.Add(new UserControl.Message(MessageType.Error, "$CS_After_Card_Transfer_Empty"));
                        ucLERunningCard.TextFocus(true, true);
                        return;
                    }

                    int len = 0;
                    try
                    {
                        len = int.Parse(aCardTransLenULE.Value.Trim());
                    }
                    catch
                    {
                        this.ucMessage.Add(new UserControl.Message(MessageType.Error, "$Error_AfterCardTransLen_Should_be_Integer"));
                        ucLERunningCard.TextFocus(true, true);
                        return;
                    }

                    if (len != this.ucLERunningCard.Value.Trim().Length)
                    {
                        this.ucMessage.Add(new UserControl.Message(MessageType.Error, "$Error_AfterCardTransLen_Not_Correct"));
                        ucLERunningCard.TextFocus(true, true);
                        return;
                    }
                }

                //首字符串检查
                if (aCardTransLetterULE.Checked)
                {
                    if (aCardTransLetterULE.Value.Trim().Length == 0)
                    {
                        this.ucMessage.Add(new UserControl.Message(MessageType.Error, "$CS_After_Card_Transfer_FLetter_Empty"));
                        ucLERunningCard.TextFocus(true, true);
                        return;
                    }

                    int index = ucLERunningCard.Value.Trim().IndexOf(aCardTransLetterULE.Value.Trim());
                    if (index != 0)
                    {
                        this.ucMessage.Add(new UserControl.Message(MessageType.Error, "$CS_After_Card_Transfer_FLetter_NotCompare"));
                        ucLERunningCard.TextFocus(true, true);
                        return;
                    }
                }
                #endregion

                #region 判断分板后序列号是否重复
                if (this._runningCardList.Contains(this.ucLERunningCard.Value.Trim().ToUpper()))
                {
                    this.ucMessage.Add(new UserControl.Message(MessageType.Error, "$Error_CS_Merge_ID_Exist"));//转换后产品序列号重复
                    this.ucLERunningCard.Value = "";

                    //Laws Lu,2005/08/11,新增焦点设置
                    ucLERunningCard.TextFocus(true, true);
                    return;
                }
                #endregion


                int rcardCount = _DataCollectFacade.GetSplitBoardCount(this.ucLERunningCard.Value.Trim().ToUpper());

                if (rcardCount > 0)
                {
                    //已经分板的序列号就不可以在分了
                    this.ucMessage.Add(new UserControl.Message(MessageType.Error, "$CS_ERROR_PRODUCT_ALREADY_SPLITE"));
                    this.ucMessage.AddBoldText(string.Format(">>$CS_Please_Input_Merge_ID {0}/{1}", this._currSequence.ToString(), this._mergeRule.ToString()));//请输入转换后产品序列号
                    ucLERunningCard.TextFocus(true, true);
                    return;
                }


                this._runningCardList.Add(this.ucLERunningCard.Value.Trim().ToUpper());
            }

            if (this._currSequence < this._mergeRule)
            {
                this._currSequence++;

                this.txtIDMergeValue.Enabled = false;
                this.ucMessage.AddBoldText(string.Format(">>$CS_Please_Input_Merge_ID {0}/{1}", this._currSequence.ToString(), this._mergeRule.ToString())); //请输入转换后产品序列号
            }
            else if (this._currSequence == this._mergeRule)                                                                                                  // 达到分板比例,写入数据库
            {
                try
                {
                    this.DataProvider.BeginTransaction();
                    int        tempCount  = 1;
                    DBDateTime dbDateTime = FormatHelper.GetNowDBDateTime(this.DataProvider);
                    foreach (string strRcard in _runningCardList)
                    {
                        #region 将ID添加到SplitBoard
                        SplitBoard splitBorad = new SplitBoard();
                        splitBorad.Seq           = tempCount;
                        splitBorad.Mocode        = simReport.MOCode;
                        splitBorad.Rcard         = strRcard;
                        splitBorad.Modelcode     = simReport.ModelCode;
                        splitBorad.Itemcode      = simReport.ItemCode;
                        splitBorad.Opcode        = simReport.OPCode;
                        splitBorad.Rescode       = ApplicationService.Current().ResourceCode;
                        splitBorad.Routecode     = simReport.RouteCode;
                        splitBorad.Scard         = simReport.SourceCard;
                        splitBorad.Segcode       = simReport.SegmentCode;
                        splitBorad.Shiftcode     = simReport.ShiftCode;
                        splitBorad.Shifttypecode = simReport.ShiftTypeCode;
                        splitBorad.Sscode        = simReport.StepSequenceCode;
                        splitBorad.Tpcode        = simReport.TimePeriodCode;
                        splitBorad.Muser         = ApplicationService.Current().UserCode;
                        splitBorad.Mdate         = dbDateTime.DBDate;
                        splitBorad.Mtime         = dbDateTime.DBTime;
                        _DataCollectFacade.AddSplitBoard(splitBorad);
                        tempCount++;
                        #endregion
                    }
                    this.DataProvider.CommitTransaction();

                    this.ucMessage.Add(new UserControl.Message(MessageType.Success, ">>$CS_SplitID_CollectSuccess"));//产品序列号转换采集成功
                    //added by jessie lee, 2005/11/29,
                }
                catch (Exception ex)
                {
                    this.DataProvider.RollbackTransaction();
                    this.ucMessage.Add(new UserControl.Message(MessageType.Error, ">>$CS_SplitID_CollectSuccess"));//产品序列号转换采集成功
                }


                this.initInput();
            }

            this.ucLERunningCard.Value = "";

            //Laws Lu,2005/08/11,新增焦点设置
            if (!aCardTransLetterULE.Checked)
            {
                ucLERunningCard.TextFocus(true, true);
            }
            else
            {
                ucLERunningCard.TextFocus(true, true);
            }
        }