Esempio n. 1
0
        private void InitializeSSCode()
        {
            string resCode = ApplicationService.Current().ResourceCode;

            BaseSetting.BaseModelFacade baseModelFacade = new BaseSetting.BaseModelFacade(this.DataProvider);
            object[] ssCodeList = baseModelFacade.GetAllStepSequence();

            if (ssCodeList != null)
            {
                this.drpSSCode.Clear();
                this.drpSSCode.AddItem("", "");
                foreach (StepSequence stepSequence in ssCodeList)
                {
                    this.drpSSCode.AddItem(stepSequence.StepSequenceDescription, stepSequence.StepSequenceCode);
                }
                this.drpSSCode.SelectedIndex = 0;
            }
        }
Esempio n. 2
0
        private OQCLot CreateNewLot(ActionEventArgs actionEventArgs, Item item, DBDateTime currentDBDateTime, bool forRework, string oldLotNo)
        {
            string  lotNoMarkCode  = forRework ? "R" : "L";
            string  lotType        = forRework ? OQCLotType.OQCLotType_ReDO : OQCLotType.OQCLotType_Normal;
            string  productionType = "";
            decimal lotSize        = 0;

            OQCFacade oqcFacade       = new OQCFacade(DataProvider);
            TryFacade tryFacade       = new TryFacade(this.DataProvider);
            OQCLot    newOQCLot       = null;
            OQCLot    objLot          = null;
            DateTime  currentDateTime = FormatHelper.ToDateTime(currentDBDateTime.DBDate, currentDBDateTime.DBTime);

            object[] tryListOfRCard  = null;
            object[] tryListOfOldLot = null;

            if (forRework)
            {
                OQCLot oldLot = oqcFacade.GetOQCLot(oldLotNo, OQCFacade.Lot_Sequence_Default) as OQCLot;

                productionType = oldLot.ProductionType;
                if (productionType == ProductionType.ProductionType_Try)
                {
                    tryListOfRCard = tryFacade.GetTryListOfRCard(actionEventArgs.ProductInfo.NowSimulation.RunningCard, item.ItemCode);
                }

                //Lot Size
                lotSize = oldLot.LotCapacity;

                tryListOfOldLot = tryFacade.GetTryListOfLotNo(oldLot.LOTNO);
            }
            else
            {
                #region 先获取产品序列号对应的工单的productionType(来自于tblmo.momemo)
                // 先获取产品序列号对应的工单的productionType(来自于tblmo.momemo)
                MO mo = (new MOFacade(DataProvider)).GetMO(actionEventArgs.ProductInfo.NowSimulation.MOCode) as MO;
                SystemSettingFacade ssf = new SystemSettingFacade(this.DataProvider);
                Parameter           param;
                param = ssf.GetParameter(mo.MOType, BenQGuru.eMES.Web.Helper.MOType.GroupType) as Parameter;
                if (param != null)
                {
                    if (string.Compare(param.ParameterValue, BenQGuru.eMES.Web.Helper.MOType.MOTYPE_RMAREWORKMOTYPE, true) == 0)
                    {
                        productionType = ProductionType.ProductionType_Claim;
                    }
                    else
                    {
                        if (string.IsNullOrEmpty(mo.MOMemo))
                        {
                            productionType = ProductionType.ProductionType_Mass;
                            mo.MOMemo      = MOProductType.MO_Product_Type_Mass.ToUpper();
                        }

                        // 根据Memo获取ProductionType
                        param = ssf.GetParameter(mo.MOMemo, MOProductType.GroupType) as Parameter;
                        //changed by hiro 08/11/10 判断param不空进行比较
                        if (param != null)
                        {
                            if (string.Compare(param.ParameterValue, MOProductType.MO_Product_Type_New, true) == 0)
                            {
                                productionType = ProductionType.ProductionType_New;
                            }
                            else if (string.Compare(param.ParameterValue, MOProductType.MO_Product_Type_Mass, true) == 0)
                            {
                                productionType = ProductionType.ProductionType_Mass;
                            }
                            else
                            {
                                throw new Exception("$Error_MOMemoNotConfig $Domain_Parameter=" + mo.MOMemo);
                            }

                            tryListOfRCard = tryFacade.GetTryListOfRCard(actionEventArgs.ProductInfo.NowSimulation.RunningCard, item.ItemCode);
                            if (tryListOfRCard != null && tryListOfRCard.Length > 0)
                            {
                                productionType = ProductionType.ProductionType_Try;
                            }
                        }
                        else
                        {
                            throw new Exception("$CS_System_Params_Losted $Domain_ParameterGroup='" + MOProductType.GroupType + "' $Domain_Parameter=" + mo.MOMemo);
                        }
                    }
                }
                else
                {
                    throw new Exception("$CS_System_Params_Losted $Domain_ParameterGroup='" + BenQGuru.eMES.Web.Helper.MOType.GroupType + "' $Domain_Parameter=" + mo.MOType);
                }
                #endregion
            }

            #region 获取ShiftDay和ShiftCode
            BaseSetting.BaseModelFacade dataModel = new BaseSetting.BaseModelFacade(this.DataProvider);
            Domain.BaseSetting.Resource res       = (Domain.BaseSetting.Resource)dataModel.GetResource(actionEventArgs.ResourceCode);
            int    shiftDay  = 0;
            string shiftCode = string.Empty;

            BaseSetting.ShiftModelFacade  shiftModel = new BaseSetting.ShiftModelFacade(this.DataProvider);
            Domain.BaseSetting.TimePeriod period     = (Domain.BaseSetting.TimePeriod)shiftModel.GetTimePeriod(res.ShiftTypeCode, currentDBDateTime.DBTime);
            if (period == null)
            {
                throw new Exception("$OutOfPerid");
            }

            shiftCode = period.ShiftCode;

            if (period.IsOverDate == Web.Helper.FormatHelper.TRUE_STRING)
            {
                if (period.TimePeriodBeginTime < period.TimePeriodEndTime)
                {
                    shiftDay = FormatHelper.TODateInt(currentDateTime.AddDays(-1));
                }
                else if (Web.Helper.FormatHelper.TOTimeInt(currentDateTime) < period.TimePeriodBeginTime)
                {
                    shiftDay = FormatHelper.TODateInt(currentDateTime.AddDays(-1));
                }
                else
                {
                    shiftDay = FormatHelper.TODateInt(currentDateTime);
                }
            }
            else
            {
                shiftDay = FormatHelper.TODateInt(currentDateTime);
            }
            #endregion

            bool needCreateNewLot  = false;
            bool needAddLotTryCode = false;

            // 获取Lot的主逻辑
            if (productionType == ProductionType.ProductionType_Try)  //试流批
            {
                object[] lotList = oqcFacade.GetLotList4TryCase(item.ItemCode, res.StepSequenceCode, lotType, productionType, lotNoMarkCode);
                if (lotList == null || lotList.Length == 0) // 找不到对应的任何试流批,则新建试流批
                {
                    needCreateNewLot  = true;
                    needAddLotTryCode = true;
                }
                else // 找到多个,则遍历每一个,找其中试流批与RCard完全一致的批,若没有则新建试流批
                {
                    object[] tryListOfLot;

                    foreach (OQCLot lotTemp in lotList)
                    {
                        tryListOfLot = tryFacade.GetTryListOfLotNo(lotTemp.LOTNO);
                        if (tryListOfRCard != null && tryListOfRCard.Length != 0 &&
                            tryListOfLot != null && tryListOfLot.Length != 0 &&
                            this.CompareTryCodeList(tryListOfRCard, tryListOfLot) == true)
                        {
                            newOQCLot = oqcFacade.GetOQCLot(lotTemp.LOTNO, lotTemp.LotSequence) as OQCLot;
                            break;
                        }
                    }

                    if (newOQCLot == null)
                    {
                        needCreateNewLot  = true;
                        needAddLotTryCode = true;
                    }
                }
            }
            else //新品批或量产批或理赔批
            {
                objLot = oqcFacade.GetMaxLot4NormalCase(item.ItemCode, res.StepSequenceCode, lotType, productionType, lotNoMarkCode);

                if (objLot == null || objLot.LOTNO == null || objLot.LOTNO == string.Empty)
                {
                    needCreateNewLot  = true;
                    needAddLotTryCode = false;
                }
                else
                {
                    newOQCLot = oqcFacade.GetOQCLot(objLot.LOTNO, OQCFacade.Lot_Sequence_Default) as OQCLot;
                }
            }

            // Added By Hi1/Venus.Feng on 20081128 for Hisense Version
            // 增加了ForRework的这个条件
            // 如果是Rework,都应该产生新的批,因为调用该函数之前,就已经by老的lot获取新的lot了,但是没有获取到
            // 才会跑到该函数中,所以在该函数中对于Rework的Case,都应该产生新的批
            // End Added
            if (needCreateNewLot || forRework)
            {
                newOQCLot = oqcFacade.CreateNewOQCLot();

                objLot = oqcFacade.GetMaxLot(res.StepSequenceCode, shiftDay, lotNoMarkCode);

                if (objLot == null || objLot.LOTNO == null || objLot.LOTNO == string.Empty)
                {
                    newOQCLot.LOTNO = res.StepSequenceCode + shiftDay.ToString() + lotNoMarkCode + "001";
                }
                else
                {
                    string oldLotNO    = objLot.LOTNO;
                    string newSequence = Convert.ToString((int.Parse(oldLotNO.Substring(oldLotNO.Length - 3, 3)) + 1));

                    newOQCLot.LOTNO = oldLotNO.Substring(0, oldLotNO.Length - 3) + newSequence.PadLeft(3, '0');
                }

                // Create New OQC Lot
                if (forRework)
                {
                    newOQCLot = oqcFacade.CreateNewOQCLot(newOQCLot.LOTNO, actionEventArgs.UserCode, currentDBDateTime,
                                                          res.OrganizationID, lotSize, res.StepSequenceCode,
                                                          item.ItemCode, oldLotNo, lotType,
                                                          productionType, res.ResourceCode, shiftDay, shiftCode);
                }
                else
                {
                    newOQCLot = oqcFacade.CreateNewOQCLot(newOQCLot.LOTNO, actionEventArgs.UserCode, currentDBDateTime,
                                                          res.OrganizationID, item.LotSize, res.StepSequenceCode,
                                                          item.ItemCode, oldLotNo, lotType,
                                                          productionType, res.ResourceCode, shiftDay, shiftCode);
                }

                oqcFacade.AddOQCLot(newOQCLot);

                if (needAddLotTryCode || forRework)
                {
                    Try2Lot try2Lot = null;
                    if (forRework)
                    {
                        if (tryListOfOldLot != null && tryListOfOldLot.Length > 0)
                        {
                            foreach (Try tempTry in tryListOfOldLot)
                            {
                                try2Lot              = tryFacade.CreateNewTry2Lot();
                                try2Lot.EAttribute1  = "";
                                try2Lot.LotNo        = newOQCLot.LOTNO;
                                try2Lot.MaintainDate = currentDBDateTime.DBDate;
                                try2Lot.MaintainTime = currentDBDateTime.DBTime;
                                try2Lot.MaintainUser = actionEventArgs.UserCode;
                                try2Lot.TryCode      = tempTry.TryCode;

                                tryFacade.AddTry2Lot(try2Lot);
                            }
                        }
                    }
                    else
                    {
                        foreach (Try tempTry in tryListOfRCard)
                        {
                            try2Lot              = tryFacade.CreateNewTry2Lot();
                            try2Lot.EAttribute1  = "";
                            try2Lot.LotNo        = newOQCLot.LOTNO;
                            try2Lot.MaintainDate = currentDBDateTime.DBDate;
                            try2Lot.MaintainTime = currentDBDateTime.DBTime;
                            try2Lot.MaintainUser = actionEventArgs.UserCode;
                            try2Lot.TryCode      = tempTry.TryCode;

                            tryFacade.AddTry2Lot(try2Lot);
                        }
                    }
                }
            }

            return(newOQCLot);
        }
Esempio n. 3
0
        private void LoadInitData()
        {
            if (product == null)
            {
                TSModel.TSModelFacade tsmodelFacade = new TSModelFacade(this.DataProvider);
                object[] objsECodeAll = tsmodelFacade.GetAllErrorCode();
                if (objsECodeAll == null || objsECodeAll.Length == 0)
                {
                    return;
                }

                ErrorCodeA[] errorsAll = new ErrorCodeA[objsECodeAll.Length];
                objsECodeAll.CopyTo(errorsAll, 0);
                this.ucErrorCodeSelect21.AddErrorCodes(errorsAll);
                this.ucErrorCodeSelect21.Focus();
                this.ucErrorCodeSelect21.FocusInput();
                return;
            }

            if (product == null || product.LastSimulation == null)
            {
                return;
            }
            ItemFacade itFacade = new ItemFacade(this.DataProvider);

            BaseSetting.BaseModelFacade baseFacade = new BaseSetting.BaseModelFacade(this.DataProvider);

            object op = null;

            if (product.LastSimulation.RouteCode != null && product.LastSimulation.RouteCode != string.Empty)
            {
                try
                {
                    op = itFacade.GetItemRoute2Operation(product.LastSimulation.ItemCode,
                                                         product.LastSimulation.RouteCode,
                                                         product.LastSimulation.OPCode);
                }
                catch { }
            }

            string strOPCode = "";

            if (op != null)
            {
                ItemRoute2OP CurrentOP = op as ItemRoute2OP;
                object       objOP2RES = baseFacade.GetOperation2Resource(CurrentOP.OPCode, this.txtResource.Value.Trim().ToUpper());
                if (objOP2RES != null)
                {
                    strOPCode = CurrentOP.OPCode;
                }
                else
                {
                    /* joe song 不知道这段代码为什么这样写,为了增加对线外工序的支持, 修改之
                     * //object objSOP = baseFacade.GetOperationByRouteAndResource(product.LastSimulation.RouteCode, this.txtResource.Value.Trim().ToUpper());
                     * //if (objSOP != null)
                     * //{
                     * //    object actOP = itFacade.GetItemRoute2Operation(product.LastSimulation.ItemCode, product.LastSimulation.RouteCode, (objSOP as Operation).OPCode);
                     * //     if (actOP != null)
                     * //    {
                     * //         CurrentOP = actOP as ItemRoute2OP;
                     * //         strOPCode = CurrentOP.OPCode;
                     * //     }
                     * // }
                     * */
                    Operation2Resource or = baseFacade.GetOperationByResource(this.txtResource.Value.Trim().ToUpper()) as Operation2Resource;
                    if (or != null)
                    {
                        strOPCode = or.OPCode;
                    }
                }
            }
            if (strOPCode == "")
            {
                Operation2Resource or = baseFacade.GetOperationByResource(this.txtResource.Value.Trim().ToUpper()) as Operation2Resource;
                if (or != null)
                {
                    strOPCode = or.OPCode;
                }
            }
            if (strOPCode == "")
            {
                return;
            }

            object[] objsECode = baseFacade.GetAllErrorCodeByOperationCode(strOPCode);
            if (objsECode == null || objsECode.Length == 0)
            {
                return;
            }

            ErrorCodeA[] errors = new ErrorCodeA[objsECode.Length];
            objsECode.CopyTo(errors, 0);
            this.ucErrorCodeSelect21.AddErrorCodes(errors);
            this.ucErrorCodeSelect21.Focus();
            this.ucErrorCodeSelect21.FocusInput();
        }
Esempio n. 4
0
        /// <summary>
        /// ** 功能描述:	确认流程卡序列号的维修
        /// ** 作 者:		crystal chu
        /// ** 日 期:		2005/07/26/
        /// ** 修 改:
        /// ** 日 期:
        /// ** nunit
        /// </summary>
        /// <param name="actionEventArgs"> </param>
        /// <returns></returns>
        public Messages Execute(ActionEventArgs actionEventArgs)
        {
            Messages         messages         = new Messages();
            DataCollectDebug dataCollectDebug = new DataCollectDebug(this.GetType().ToString() + "Collect");

            dataCollectDebug.WhenFunctionIn(messages);
            try
            {
                ActionOnLineHelper dataCollect = new ActionOnLineHelper(this.DataProvider);
                //检查res在不在OPTS中
                messages.AddMessages(dataCollect.CheckResourceInOperationTS(actionEventArgs));

                //Laws Lu,2006/11/13 uniform system collect date
                DBDateTime dbDateTime;
                //Laws Lu,2006/11/13 uniform system collect date
                if (actionEventArgs.ProductInfo != null && actionEventArgs.ProductInfo.WorkDateTime != null)
                {
                    dbDateTime = actionEventArgs.ProductInfo.WorkDateTime;
                }
                else
                {
                    dbDateTime = FormatHelper.GetNowDBDateTime(DataProvider);
                    if (actionEventArgs.ProductInfo != null)
                    {
                        actionEventArgs.ProductInfo.WorkDateTime = dbDateTime;
                    }
                }

                DateTime dtNow = FormatHelper.ToDateTime(dbDateTime.DBDate, dbDateTime.DBTime);
                if (messages.IsSuccess())
                {
                    //Laws Lu,2005/09/16,修改	整理逻辑
                    TSFacade tsFacade = new TSFacade(this.DataProvider);
                    //					if( !tsFacade.IsCardInTS(actionEventArgs.RunningCard))
                    //					{
                    //						messages.Add(new Message(MessageType.Error,"$CSError_Card_Not_In_TS"));
                    //					}
                    //Laws Lu,2005/10/16,在订单1中的已经拆解的产品序列号,
                    //现在系统中可以实现将该产品序列号重新归属到另外一个订单2,
                    //但是该产品序列号在工单2采集完不良后,
                    //作送修作业时,系统提出报错信息:
                    //该产品状态为“拆解”状态。导致该产品序列号无法进行维修。
                    object obj = tsFacade.GetCardLastTSRecordInNewStatus(actionEventArgs.RunningCard);

                    if (obj == null)
                    {
                        //Laws Lu,2006,07/05 Support RMA Repair
                        //						if(actionEventArgs.IsRMA)
                        //						{
                        MOFacade moFAC  = new MOFacade(DataProvider);
                        object   objRMA = moFAC.GetRepairRMARCARDByRcard(actionEventArgs.RunningCard);
                        if (objRMA != null)
                        {
                            #region 新增维修信息

                            RMARCARD     rma = objRMA as RMARCARD;
                            Domain.TS.TS tS  = tsFacade.CreateNewTS();
                            tS.TSId = FormatHelper.GetUniqueID((rma.REWORKMOCODE == String.Empty?rma.RMABILLNO:rma.REWORKMOCODE)
                                                               , actionEventArgs.RunningCard, ActionOnLineHelper.StartSeq.ToString());

                            tS.CardType      = CardType.CardType_Product;;
                            tS.FormTime      = rma.MTIME;
                            tS.FromDate      = rma.MDATE;
                            tS.FromInputType = TSFacade.TSSource_RMA;
                            tS.FromUser      = rma.MUSER;
                            tS.FromMemo      = rma.EATTRIBUTE1;
                            //Laws Lu,2006/07/05 add support RMA
                            tS.RMABillCode = rma.RMABILLNO;
                            //工作时间和工业布局信息

                            //Laws Lu,2005/11/09,新增	记录ShiftDay
                            BaseSetting.BaseModelFacade dataModel = new BaseSetting.BaseModelFacade(this.DataProvider);
                            Domain.BaseSetting.Resource res       = (Domain.BaseSetting.Resource)dataModel.GetResource(actionEventArgs.ResourceCode);
                            //onwip.SegmentCode				= productInfo.NowSimulationReport.SegmentCode;
                            //2006/11/17,Laws Lu add get DateTime from db Server

                            BaseSetting.ShiftModelFacade  shiftModel = new BaseSetting.ShiftModelFacade(this.DataProvider);
                            Domain.BaseSetting.TimePeriod period     = (Domain.BaseSetting.TimePeriod)shiftModel.GetTimePeriod(res.ShiftTypeCode, Web.Helper.FormatHelper.TOTimeInt(dtNow));
                            if (period == null)
                            {
                                throw new Exception("$OutOfPerid");
                            }

                            if (period.IsOverDate == Web.Helper.FormatHelper.TRUE_STRING)
                            {
                                if (period.TimePeriodBeginTime < period.TimePeriodEndTime)
                                {
                                    tS.FromShiftDay = FormatHelper.TODateInt(dtNow.AddDays(-1));
                                }
                                else if (Web.Helper.FormatHelper.TOTimeInt(dtNow) < period.TimePeriodBeginTime)
                                {
                                    tS.FromShiftDay = FormatHelper.TODateInt(dtNow.AddDays(-1));
                                }
                                else
                                {
                                    tS.FromShiftDay = FormatHelper.TODateInt(dtNow);
                                }
                            }
                            else
                            {
                                tS.FromShiftDay = FormatHelper.TODateInt(dtNow);
                            }

                            tS.FromOPCode           = "TS";
                            tS.FromResourceCode     = actionEventArgs.ResourceCode;
                            tS.FromRouteCode        = String.Empty;
                            tS.FromSegmentCode      = res.SegmentCode;
                            tS.FromShiftCode        = period.ShiftCode;                     /*Laws Lu,2006/03/11 修正班次填写有误*/
                            tS.FromShiftTypeCode    = period.ShiftTypeCode;
                            tS.FromStepSequenceCode = res.StepSequenceCode;
                            tS.FromTimePeriodCode   = period.TimePeriodCode;

                            tS.ItemCode     = rma.ITEMCODE;
                            tS.MaintainDate = FormatHelper.TODateInt(dtNow);
                            tS.MaintainTime = FormatHelper.TOTimeInt(dtNow);
                            tS.MaintainUser = actionEventArgs.MaintainUser;

                            tS.MOCode              = (rma.REWORKMOCODE == String.Empty?rma.RMABILLNO:rma.REWORKMOCODE);
                            tS.ModelCode           = rma.MODELCODE;
                            tS.RunningCard         = actionEventArgs.RunningCard;
                            tS.RunningCardSequence = ActionOnLineHelper.StartSeq;
                            tS.SourceCard          = actionEventArgs.RunningCard;
                            tS.SourceCardSequence  = ActionOnLineHelper.StartSeq;
                            tS.TransactionStatus   = TSFacade.TransactionStatus_None;

                            tS.TranslateCard         = actionEventArgs.RunningCard;
                            tS.TranslateCardSequence = ActionOnLineHelper.StartSeq;
                            //tS.TSStatus = TSStatus.TSStatus_New;

                            tS.Week    = (new ReportHelper(DataProvider)).WeekOfYear(tS.FromShiftDay.ToString());
                            tS.Month   = int.Parse(tS.FromShiftDay.ToString().Substring(4, 2));
                            tS.TSTimes = ActionOnLineHelper.StartNGTimes;

                            tS.ConfirmUser         = actionEventArgs.UserCode;
                            tS.ConfirmDate         = FormatHelper.TODateInt(dtNow);
                            tS.ConfirmTime         = FormatHelper.TOTimeInt(dtNow);
                            tS.ConfirmOPCode       = "TS";
                            tS.ConfirmResourceCode = actionEventArgs.ResourceCode;
                            tS.TSStatus            = TSStatus.TSStatus_Confirm;
                            // Added by Icyer 2007/07/03
                            MO mo = (MO)moFAC.GetMO(tS.MOCode);
                            if (mo != null)
                            {
                                tS.MOSeq = mo.MOSeq;
                            }
                            // Added end

                            tsFacade.AddTS(tS);
                            //Laws Lu,2006/07/07 add ,Success release than delete rma
                            moFAC.DeleteRMARCARD(rma);
                            #endregion
                        }
                        else
                        {
                            messages.Add(new Message(MessageType.Error, "$CSError_Card_Not_In_TS_OR_Status_Error"));
                        }
                        //						}
                        //						else
                        //						{
                        //							messages.Add(new Message(MessageType.Error,"$CSError_Card_Not_In_TS_OR_Status_Error"));
                        //						}
                    }
                    else
                    {
                        BenQGuru.eMES.Domain.TS.TS ts = (BenQGuru.eMES.Domain.TS.TS)obj;

                        if (ts.TSStatus == TSStatus.TSStatus_New)
                        {
                            ts.ConfirmUser         = actionEventArgs.UserCode;
                            ts.ConfirmDate         = FormatHelper.TODateInt(dtNow);
                            ts.ConfirmTime         = FormatHelper.TOTimeInt(dtNow);
                            ts.ConfirmOPCode       = "TS";
                            ts.ConfirmResourceCode = actionEventArgs.ResourceCode;
                            ts.TSStatus            = TSStatus.TSStatus_Confirm;

                            //added by jessie lee, 2005/11/24,
                            ts.MaintainUser = actionEventArgs.MaintainUser;
                            ts.MaintainDate = FormatHelper.TODateInt(dtNow);
                            ts.MaintainTime = FormatHelper.TOTimeInt(dtNow);

                            tsFacade.UpdateTSConfirmStatus(ts);
                        }
                        else
                        {
                            messages.Add(new Message(MessageType.Error, "$CSError_Card_TSStatus_Error $Current_Status $" + ts.TSStatus));
                        }
                    }
                }
            }
            catch (Exception e)
            {
                messages.Add(new Message(e));
            }
            dataCollectDebug.WhenFunctionOut(messages);
            return(messages);
        }
Esempio n. 5
0
        /// <summary>
        /// 维修完成
        /// </summary>
        /// <param name="actionEventArgs"></param>
        /// <returns></returns>
        public Messages Execute(ActionEventArgs actionEventArgs)
        {
            Messages         messages         = new Messages();
            DataCollectDebug dataCollectDebug = new DataCollectDebug(this.GetType().ToString() + "Collect");

            dataCollectDebug.WhenFunctionIn(messages);
            try
            {
                ActionOnLineHelper dataCollect = new ActionOnLineHelper(this.DataProvider);
                //检查res在不在OPTS中
                // Modified By Hi1/Venus.Feng on 20080711 for Hisense Version : 对于自动作Reflow的动作来讲,不再Check Resource是否在回流的工序中
                if (((TSActionEventArgs)actionEventArgs).IgnoreResourceInOPTS != true)
                {
                    messages.AddMessages(dataCollect.CheckResourceInOperationTS(actionEventArgs));
                }
                // End Modified

                if (messages.IsSuccess())
                {
                    TSFacade tsFacade = new TSFacade(this.DataProvider);
                    //					if( !tsFacade.IsCardInTS(actionEventArgs.RunningCard))
                    //					{
                    //						messages.Add(new Message(MessageType.Error,"$CSError_Card_Not_In_TS"));
                    //					}
                    //					if(messages.IsSuccess())
                    //					{

                    //Laws Lu,2005/09/16,修改	逻辑调整P4.8
                    object obj = tsFacade.GetCardLastTSRecord(actionEventArgs.RunningCard);



                    if (obj == null)
                    {
                        messages.Add(new Message(MessageType.Error, "$CSError_Card_Not_In_TS"));
                        //messages.Add(new Message(MessageType.Error,"$CSError_Card_TSStatus_IsNot_TS"));
                    }
                    else
                    {
                        Domain.TS.TS ts = (Domain.TS.TS)obj;



                        if (ts.TSStatus == TSStatus.TSStatus_Scrap ||
                            ts.TSStatus == TSStatus.TSStatus_Split ||
                            ts.TSStatus == TSStatus.TSStatus_Reflow ||
                            ts.TSStatus == TSStatus.TSStatus_Confirm)
                        {
                            messages.Add(new Message(MessageType.Error, "$CSError_Card_TSStatus_IsNot_TS $Current_Status $" + ts.TSStatus));
                        }


                        if (messages.IsSuccess())
                        {
                            //2006/11/17,Laws Lu add get DateTime from db Server
                            DBDateTime dbDateTime = FormatHelper.GetNowDBDateTime(DataProvider);

                            DateTime dtNow = FormatHelper.ToDateTime(dbDateTime.DBDate, dbDateTime.DBTime);

                            //修改 Karron Qiu,2005-9-26
                            if (ts.FromInputType == TS.TSFacade.TSSource_OnWIP)//线上.必须是回流或者报废
                            {
                                if (((TSActionEventArgs)actionEventArgs).TSStatus == TSStatus.TSStatus_Complete)
                                {
                                    messages.Add(new Message(MessageType.Error, "$CSError_Please_Select_Reflow_OR_Scrap"));//请选择回流或者报废
                                }
                            }
                            else if (ts.FromInputType == TS.TSFacade.TSSource_TS)//离线. 不能回流
                            {
                                if (((TSActionEventArgs)actionEventArgs).TSStatus == TSStatus.TSStatus_Reflow)
                                {
                                    messages.Add(new Message(MessageType.Error, "$CSError_Offline_Cannot_Reflow"));//离线不能回流
                                }
                            }
                            else if (ts.FromInputType == TS.TSFacade.TSSource_RMA)//RMA. 不能回流
                            {
                                if (((TSActionEventArgs)actionEventArgs).TSStatus == TSStatus.TSStatus_Reflow)
                                {
                                    messages.Add(new Message(MessageType.Error, "$CSError_RMATS_Cannot_Reflow"));//RMA不能回流
                                }
                            }



                            //Laws Lu,2005/11/09,新增	记录ShiftDay
                            BaseSetting.BaseModelFacade dataModel = new BaseSetting.BaseModelFacade(this.DataProvider);
                            Domain.BaseSetting.Resource res       = (Domain.BaseSetting.Resource)dataModel.GetResource(actionEventArgs.ResourceCode);
                            //onwip.SegmentCode				= productInfo.NowSimulationReport.SegmentCode;

                            BaseSetting.ShiftModelFacade  shiftModel = new BaseSetting.ShiftModelFacade(this.DataProvider);
                            Domain.BaseSetting.TimePeriod period     = (Domain.BaseSetting.TimePeriod)shiftModel.GetTimePeriod(res.ShiftTypeCode, Web.Helper.FormatHelper.TOTimeInt(dtNow));

                            int shiftDay = 0;
                            if (period == null)
                            {
                                throw new Exception("$OutOfPerid");
                            }

                            if (period.IsOverDate == Web.Helper.FormatHelper.TRUE_STRING)
                            {
                                if (period.TimePeriodBeginTime < period.TimePeriodEndTime)
                                {
                                    shiftDay = FormatHelper.TODateInt(dtNow.AddDays(-1));
                                }
                                else if (Web.Helper.FormatHelper.TOTimeInt(dtNow) < period.TimePeriodBeginTime)
                                {
                                    shiftDay = FormatHelper.TODateInt(dtNow.AddDays(-1));
                                }
                                else
                                {
                                    shiftDay = FormatHelper.TODateInt(dtNow);
                                }
                            }
                            else
                            {
                                shiftDay = FormatHelper.TODateInt(dtNow);
                            }

                            #region 报废
                            if (((TSActionEventArgs)actionEventArgs).TSStatus == TSStatus.TSStatus_Scrap)
                            {
                                if (ts.TSStatus == TSStatus.TSStatus_TS || ts.TSStatus == TSStatus.TSStatus_Confirm)
                                {
                                    ts.TSStatus       = TSStatus.TSStatus_Scrap;
                                    ts.TSResourceCode = actionEventArgs.ResourceCode;
                                    ts.TSUser         = actionEventArgs.UserCode;

                                    ts.TSDate = shiftDay;
                                    ts.TSTime = FormatHelper.TOTimeInt(dtNow);

                                    //added by jessie lee, 2005/11/24,
                                    //新增报废原因
                                    ts.ScrapCause   = (actionEventArgs as TSActionEventArgs).ScrapCause;
                                    ts.MaintainUser = (actionEventArgs as TSActionEventArgs).MaintainUser;
                                    ts.MaintainDate = ts.TSDate;
                                    ts.MaintainTime = ts.TSTime;

                                    //TODO:Laws Lu,2005/11/09,需要优化
                                    tsFacade.UpdateTS(ts);

                                    //added by alex,2010/11/09
                                    BenQGuru.eMES.OQC.OQCFacade oqcFacade = new BenQGuru.eMES.OQC.OQCFacade(this.DataProvider);
                                    OQCLot2Card oqcLot2Card = oqcFacade.GetLastOQCLot2CardByRCard(actionEventArgs.RunningCard) as OQCLot2Card;
                                    if (oqcLot2Card != null)
                                    {
                                        oqcLot2Card.Status = "SCRAP";
                                        oqcFacade.UpdateOQCLot2Card(oqcLot2Card);
                                    }

                                    MOFacade moFAC = new MOFacade(this._domainDataProvider);

                                    if (ts.FromInputType == TSFacade.TSSource_OnWIP)
                                    {
                                        //Laws Lu,2005/08/19,新增
                                        //Laws Lu,2005/08/25,修改	处理报废时,更新工单的报废数量
                                        doAction(actionEventArgs);
                                    }
                                }
                                else
                                {
                                    messages.Add(new Message(MessageType.Error, "$CSError_Card_TSStatus_IsNot_TS_OR_Confirm"));
                                }
                            }
                            #endregion

                            #region 完成
                            if (((TSActionEventArgs)actionEventArgs).TSStatus == TSStatus.TSStatus_Complete)
                            {
                                if (ts.TSStatus == TSStatus.TSStatus_TS)
                                {
                                    ts.TSStatus = TSStatus.TSStatus_Complete;

                                    ts.TSTimes = 1;

                                    //added by jessie lee, 2005/11/24,
                                    ts.MaintainUser = (actionEventArgs as TSActionEventArgs).MaintainUser;
                                    ts.TSUser       = actionEventArgs.UserCode;
                                    ts.MaintainDate = FormatHelper.TODateInt(dtNow);
                                    ts.MaintainTime = FormatHelper.TOTimeInt(dtNow);
                                    //Laws Lu,2006/04/28 add 添加维修shiftday和维修resourcecode
                                    ts.TSDate         = shiftDay;
                                    ts.TSTime         = FormatHelper.TOTimeInt(dtNow);
                                    ts.TSResourceCode = actionEventArgs.ResourceCode;


                                    tsFacade.UpdateTS(ts);

                                    // Added by Icyer 2006/11/07, KeyPart维修完成
                                    if (ts.CardType == CardType.CardType_Part && ts.FromInputType == TSFacade.TSSource_TS)
                                    {
                                        DataCollectFacade dataCollectFacade = new DataCollectFacade(this.DataProvider);
                                        SimulationReport  simRpt            = dataCollectFacade.GetLastSimulationReport(ts.RunningCard);
                                        if (simRpt != null && simRpt.Status == ProductStatus.NG)
                                        {
                                            simRpt.Status = ProductStatus.GOOD;
                                            dataCollectFacade.UpdateSimulationReport(simRpt);
                                        }
                                    }
                                    // Added end
                                }
                                else
                                {
                                    messages.Add(new Message(MessageType.Error, "$CSError_Card_TSStatus_IsNot_TS $Current_Status $" + ts.TSStatus));
                                }
                            }
                            #endregion

                            #region 回流
                            if (((TSActionEventArgs)actionEventArgs).TSStatus == TSStatus.TSStatus_Reflow)
                            {
                                if (ts.TSStatus == TSStatus.TSStatus_TS)
                                {
                                    ts.TSStatus     = TSStatus.TSStatus_Reflow;
                                    ts.ReflowMOCode = ((TSActionEventArgs)actionEventArgs).MOCode;
                                    //ts.ReflowResourceCode = ((TSActionEventArgs)actionEventArgs).ItemCode ;
                                    ts.ReflowRouteCode = ((TSActionEventArgs)actionEventArgs).RouteCode;
                                    ts.ReflowOPCode    = ((TSActionEventArgs)actionEventArgs).OPCode;

                                    //added by jessie lee, 2005/11/24,
                                    //added by jessie lee, 2005/11/24,
                                    ts.MaintainUser = (actionEventArgs as TSActionEventArgs).MaintainUser;
                                    ts.TSUser       = actionEventArgs.UserCode;
                                    ts.MaintainDate = FormatHelper.TODateInt(dtNow);
                                    ts.MaintainTime = FormatHelper.TOTimeInt(dtNow);

                                    //Laws Lu,2006/04/28 add 添加维修shiftday和维修resourcecode
                                    ts.TSDate         = shiftDay;
                                    ts.TSTime         = FormatHelper.TOTimeInt(dtNow);
                                    ts.TSResourceCode = actionEventArgs.ResourceCode;

                                    tsFacade.UpdateTSReflowStatus(ts);
                                }
                                else
                                {
                                    messages.Add(new Message(MessageType.Error, "$CSError_Card_TSStatus_IsNot_TS $Current_Status $" + ts.TSStatus));
                                }
                            }
                            #endregion
                        }
                    }
                }
            }
            catch (Exception e)
            {
                messages.Add(new Message(e));
            }
            dataCollectDebug.WhenFunctionOut(messages);
            return(messages);
        }