Example #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="actionEventArgs"> </param> params (0,lotno)
        /// <returns></returns>
        public Messages Execute(ActionEventArgs actionEventArgs)
        {
            Messages         messages         = new Messages();
            DataCollectDebug dataCollectDebug = new DataCollectDebug(this.GetType().ToString() + "Collect");

            dataCollectDebug.WhenFunctionIn(messages);
            OQCRejectEventArgs oqcRejectEventArgs = actionEventArgs as OQCRejectEventArgs;

            try
            {
                ActionOnLineHelper dataCollect  = new ActionOnLineHelper(this.DataProvider);
                ActionOQCHelper    oqcHelper    = new ActionOQCHelper(this.DataProvider);
                OQCFacade          oqcFacade    = new OQCFacade(this.DataProvider);
                ReworkFacade       reworkFacade = new ReworkFacade(this.DataProvider);
                TSFacade           tsFacade     = new TSFacade(this.DataProvider);

                //check oqcStatus
                #region CheckOQCLotStatus
                //				object objOQClot = oqcFacade.GetOQCLot(oqcRejectEventArgs.OQCLotNO,OQCFacade.Lot_Sequence_Default);
                //				if(objOQClot == null)
                //				{
                //					throw new Exception("$Error_OQCLotNotExisted");
                //				}
                //				if( ((OQCLot)objOQClot).LOTStatus == OQCLotStatus.OQCLotStatus_Initial)
                //				{
                //					throw new Exception("$Error_OQCLotNO_Cannot_Initial");
                //				}
                //				if( ((OQCLot)objOQClot).LOTStatus == OQCLotStatus.OQCLotStatus_NoExame)
                //				{
                //					throw new Exception("$Error_OQCLotNO_Cannot_NoExame");
                //				}
                //				if( (((OQCLot)objOQClot).LOTStatus == OQCLotStatus.OQCLotStatus_Reject)||((((OQCLot)objOQClot).LOTStatus == OQCLotStatus.OQCLotStatus_Pass)  ))
                //				{
                //					throw new Exception("$Error_OQCLotNO_HasComplete");
                //				}
                #endregion

                if (!oqcRejectEventArgs.IsForceReject)
                {
                    //必须要有NG而且在送修状态的板子
                    if (tsFacade.HaveNewStatusCardInOQCLot(oqcRejectEventArgs.OQCLotNO, String.Empty))
                    {
                        throw new Exception("$Error_OQCLotNo_HasNoTS");
                    }
                }

                object objLot = null;
                if (oqcRejectEventArgs.Lot == null)
                {
                    objLot = oqcFacade.GetExamingOQCLot(oqcRejectEventArgs.OQCLotNO, OQCFacade.Lot_Sequence_Default);
                }
                else
                {
                    objLot = oqcRejectEventArgs.Lot;
                }

                //update each running card reject
                #region 取得每个板子进行批退,填充reject,Reject2ErrorCode信息
                //reject
                object[] RCards = null;

                if (oqcRejectEventArgs.CardOfLot != null)
                {
                    RCards = oqcRejectEventArgs.CardOfLot;
                }
                else
                {
                    RCards = oqcHelper.QueryCardOfLot(oqcRejectEventArgs.OQCLotNO, OQCFacade.Lot_Sequence_Default);
                }

                if (!oqcRejectEventArgs.IsForceReject)
                {
                    int iNGCount = 0;
                    for (int j = 0; j < RCards.Length; j++)
                    {
                        if (((Simulation)RCards[j]).ProductStatus == ProductStatus.NG)
                        {
                            iNGCount = 1;
                            break;
                        }
                    }
                    int funcNGCount = 0;
                    funcNGCount = oqcFacade.QueryFuncTesCount(oqcRejectEventArgs.OQCLotNO, OQCFacade.Lot_Sequence_Default.ToString(), ProductStatus.NG);
                    if (iNGCount == 0 && funcNGCount == 0)
                    {
                        throw new Exception("$CS_LOT_NOT_EXIST_NG");
                    }
                }

                #region reject errorCodes
                object[]         objs             = oqcFacade.ExtraQueryOQCLotCard2ErrorCode(oqcRejectEventArgs.OQCLotNO, OQCFacade.Lot_Sequence_Default.ToString());
                Reject2ErrorCode reject2ErrorCode = reworkFacade.CreateNewReject2ErrorCode();
                //Reject2ErrorCode
                if (objs != null)
                {
                    for (int i = 0; i < objs.Length; i++)
                    {
                        bool needInsert = false;
                        foreach (Simulation sim in RCards)
                        {
                            if (sim.RunningCard == ((OQCLotCard2ErrorCode)objs[i]).RunningCard &&
                                sim.RunningCardSequence == ((OQCLotCard2ErrorCode)objs[i]).RunningCardSequence)
                            {
                                needInsert = true;
                            }
                        }
                        if (needInsert)
                        {
                            reject2ErrorCode.ErrorCode           = ((OQCLotCard2ErrorCode)objs[i]).ErrorCode;
                            reject2ErrorCode.ErrorCodeGroup      = ((OQCLotCard2ErrorCode)objs[i]).ErrorCodeGroup;
                            reject2ErrorCode.MaintainUser        = actionEventArgs.UserCode;
                            reject2ErrorCode.RunningCard         = ((OQCLotCard2ErrorCode)objs[i]).RunningCard;
                            reject2ErrorCode.RunningCardSequence = ((OQCLotCard2ErrorCode)objs[i]).RunningCardSequence + 1;
                            reject2ErrorCode.MOCode = ((OQCLotCard2ErrorCode)objs[i]).MOCode;
                            reject2ErrorCode.LotNo  = ((OQCRejectEventArgs)actionEventArgs).OQCLotNO;
                            reject2ErrorCode.MOSeq  = ((OQCLotCard2ErrorCode)objs[i]).MOSeq;        // Added by Icyer 2007/07/03

                            if (reworkFacade.GetReject2ErrorCode(reject2ErrorCode.ErrorCode, reject2ErrorCode.RunningCard, reject2ErrorCode.RunningCardSequence, reject2ErrorCode.ErrorCodeGroup) == null)
                            {
                                reworkFacade.AddReject2ErrorCode(reject2ErrorCode);
                            }
                        }
                    }
                }
                #endregion

                #endregion

                #region OQCLotCheckList
                object objLotCheckList = oqcFacade.GetOQCLOTCheckList(oqcRejectEventArgs.OQCLotNO, OQCFacade.Lot_Sequence_Default);
                if (objLotCheckList != null)
                {
                    OQCLOTCheckList oqcLotCheckList = objLotCheckList as OQCLOTCheckList;
                    oqcLotCheckList.Result = OQCLotStatus.OQCLotStatus_Reject;
                    oqcFacade.UpdateOQCLOTCheckList(oqcLotCheckList);
                }
                #endregion

                //把整个lot中的ID全变成reject
                #region 整个lot中的ID全变成reject
                object[] objsInTS = oqcFacade.GetOQCLot2CardInTS(string.Empty, string.Empty, string.Empty, string.Empty, oqcRejectEventArgs.OQCLotNO, OQCFacade.Lot_Sequence_Default.ToString());
                if (objsInTS == null)
                {
                    oqcFacade.UpdateOQCLot2CardByOQCResult(oqcRejectEventArgs.OQCLotNO, OQCFacade.Lot_Sequence_Default.ToString(), string.Empty, string.Empty, ProductStatus.Reject, true);
                }
                else
                {
                    string tmpString = string.Empty;
                    for (int i = 0; i < objsInTS.Length; i++)
                    {
                        tmpString += ": " + ((OQCLot2Card)objsInTS[i]).RunningCard;
                    }
                    throw new Exception(String.Format("$Error_RunningCardInTS: {0}", tmpString));
                }
                #endregion

                messages.AddMessages(SetReworkInformation(messages, RCards, oqcRejectEventArgs, dataCollect, reworkFacade));

                #region updateOQCLot

                DBDateTime dbDateTime;

                dbDateTime = FormatHelper.GetNowDBDateTime(DataProvider);

                OQCLot oqcLot = objLot as OQCLot;
                oqcLot.LOTStatus = OQCLotStatus.OQCLotStatus_Reject;
                oqcLot.DealDate  = dbDateTime.DBDate;
                oqcLot.DealTime  = dbDateTime.DBTime;
                oqcLot.DealUser  = actionEventArgs.UserCode;
                oqcLot.Memo      = oqcRejectEventArgs.Memo;
                oqcFacade.UpdateOQCLotStatus(oqcLot);
                #endregion

                if (oqcRejectEventArgs.IsAutoGenerateReworkSheet)
                {
                    //ReworkSheet reworkSheet = reworkFacade.GetMaxReworkSheet(dbDateTime.DBDate);
                    //reworkSheet.ReworkCode = reworkSheet.ReworkCode.Substring(0, 9) + Convert.ToString(int.Parse(reworkSheet.ReworkCode.Substring(9, 3)) + 1).PadLeft(3, '0');
                    ReworkSheet reworkSheet = new ReworkSheet();
                    reworkSheet.ReworkCode       = oqcLot.LOTNO;
                    reworkSheet.CreateDate       = dbDateTime.DBDate;
                    reworkSheet.CreateTime       = dbDateTime.DBTime;
                    reworkSheet.CreateUser       = actionEventArgs.UserCode;
                    reworkSheet.Department       = "";
                    reworkSheet.EAttribute1      = "";
                    reworkSheet.ItemCode         = (RCards[0] as Simulation).ItemCode;
                    reworkSheet.LotList          = oqcRejectEventArgs.OQCLotNO;
                    reworkSheet.MaintainDate     = dbDateTime.DBDate;
                    reworkSheet.MaintainTime     = dbDateTime.DBTime;
                    reworkSheet.MaintainUser     = actionEventArgs.UserCode;
                    reworkSheet.MOCode           = "";
                    reworkSheet.NeedCheck        = "N";
                    reworkSheet.NewMOCode        = "";
                    reworkSheet.NewOPBOMCode     = "";
                    reworkSheet.NewOPBOMVersion  = "";
                    reworkSheet.NewOPCode        = "";
                    reworkSheet.NewRouteCode     = "";
                    reworkSheet.ReasonAnalyse    = "";
                    reworkSheet.ReworkContent    = "";
                    reworkSheet.ReworkDate       = 0;
                    reworkSheet.ReworkHC         = 0;
                    reworkSheet.ReworkMaxQty     = 0;
                    reworkSheet.ReworkQty        = RCards.Length;
                    reworkSheet.ReworkRealQty    = 0;
                    reworkSheet.ReworkReason     = oqcRejectEventArgs.Memo;
                    reworkSheet.ReworkSourceCode = " ";
                    reworkSheet.ReworkTime       = 0;
                    reworkSheet.ReworkType       = ReworkType.REWORKTYPE_ONLINE;
                    reworkSheet.Soluation        = "";
                    reworkSheet.Status           = ReworkStatus.REWORKSTATUS_RELEASE;
                    reworkSheet.AutoLot          = oqcRejectEventArgs.IsCreateNewLot ? "Y" : "";

                    reworkFacade.AddReworkSheetWithOutTrans(reworkSheet);
                }

                //add by roger.xue 2008/10/27
                if (oqcRejectEventArgs.IsUnFrozen)
                {
                    oqcFacade.UpdateUnFrozenOnLot(oqcRejectEventArgs.OQCLotNO, oqcRejectEventArgs.UnFrozenReason,
                                                  dbDateTime.DBDate, dbDateTime.DBTime, oqcRejectEventArgs.UserCode, OQCFacade.Lot_Sequence_Default);

                    oqcFacade.UnFreezeFrozen(oqcRejectEventArgs.OQCLotNO, oqcRejectEventArgs.UnFrozenReason,
                                             dbDateTime.DBDate, dbDateTime.DBTime, oqcRejectEventArgs.UserCode, OQCFacade.Lot_Sequence_Default);
                }
                //end add

                AlertFacade alertFacade = new AlertFacade(this.DataProvider);
                alertFacade.AlertOQCReject(oqcLot.ItemCode, oqcLot.SSCode, oqcLot.LOTNO, oqcLot.Memo);
            }
            catch (Exception e)
            {
                messages.Add(new Message(e));
            }
            dataCollectDebug.WhenFunctionOut(messages);
            return(messages);
        }