Ejemplo n.º 1
0
        private Messages SetRCardReflowByErrorCode(ActionEventArgs actionEventArgs)
        {
            Messages messages  = new Messages();
            string   routeCode = "";
            string   opCode    = "";

            System.Collections.Generic.List <string> listErrorCode = new System.Collections.Generic.List <string>();

            if (((TSActionEventArgs)actionEventArgs).ErrorCodes != null)
            {
                ErrorCodeGroup2ErrorCode[] error = new ErrorCodeGroup2ErrorCode[((TSActionEventArgs)actionEventArgs).ErrorCodes.Length];
                ((TSActionEventArgs)actionEventArgs).ErrorCodes.CopyTo(error, 0);
                for (int i = 0; i < error.Length; i++)
                {
                    if (error[i].ErrorCode != "" && listErrorCode.Contains(error[i].ErrorCode) == false)
                    {
                        listErrorCode.Add(error[i].ErrorCode);
                    }
                }
            }
            if (listErrorCode.Count == 0)
            {
                return(messages);
            }

            // 查询不良代码和产品对应的返工途程
            TSModel.TSModelFacade tsmodelFacade = new BenQGuru.eMES.TSModel.TSModelFacade(this.DataProvider);
            object objErrorCode2OPRework        = tsmodelFacade.GetErrorCode2OPRework(actionEventArgs.ProductInfo.NowSimulation.OPCode,
                                                                                      listErrorCode[0], GlobalVariables.CurrentOrganizations.First().OrganizationID);

            object             tempOPRework;
            ErrorCode2OPRework tempErrorCode2OPRework;

            if (objErrorCode2OPRework == null)
            {
                for (int i = 1; i < listErrorCode.Count; i++)
                {
                    tempOPRework = tsmodelFacade.GetErrorCode2OPRework(actionEventArgs.ProductInfo.NowSimulation.OPCode,
                                                                       listErrorCode[i], GlobalVariables.CurrentOrganizations.First().OrganizationID);
                    if (tempOPRework != null)
                    {
                        messages.Add(new Message(MessageType.Error, "$Error_ErrorCodeHaveMoreThanOneRoute"));
                        return(messages);
                    }
                }
                return(messages);
            }
            else
            {
                ErrorCode2OPRework firstErrorCode2OPRework = objErrorCode2OPRework as ErrorCode2OPRework;
                for (int i = 1; i < listErrorCode.Count; i++)
                {
                    tempOPRework = tsmodelFacade.GetErrorCode2OPRework(actionEventArgs.ProductInfo.NowSimulation.OPCode,
                                                                       listErrorCode[i], GlobalVariables.CurrentOrganizations.First().OrganizationID);

                    if (tempOPRework == null)
                    {
                        messages.Add(new Message(MessageType.Error, "$Error_ErrorCodeHaveMoreThanOneRoute"));
                        return(messages);
                    }
                    else
                    {
                        tempErrorCode2OPRework = tempOPRework as ErrorCode2OPRework;
                        if (tempErrorCode2OPRework.RouteCode != firstErrorCode2OPRework.RouteCode ||
                            tempErrorCode2OPRework.ToOPCode != firstErrorCode2OPRework.ToOPCode)
                        {
                            messages.Add(new Message(MessageType.Error, "$Error_ErrorCodeHaveMoreThanOneRoute"));
                            return(messages);
                        }
                    }
                }

                opCode    = firstErrorCode2OPRework.ToOPCode;
                routeCode = firstErrorCode2OPRework.RouteCode;
                if (string.Compare(opCode, "TS", true) == 0)
                {
                    return(messages);
                }
            }

            if (routeCode.Trim().Length == 0)  // 如果途程等于空,则将当前序列号的途程作为返工途程
            {
                routeCode = actionEventArgs.ProductInfo.NowSimulation.RouteCode;
            }

            // 检查产品与途程的对应
            ItemFacade   itemFacade = new ItemFacade(this.DataProvider);
            ItemRoute2OP op         = (ItemRoute2OP)itemFacade.GetItemRoute2Operation(actionEventArgs.ProductInfo.NowSimulation.ItemCode, routeCode, opCode);

            if (op == null)
            {
                messages.Add(new Message(MessageType.Error, "$Error_ReworkRouteNotBelongToItem [" + routeCode + "]"));
                return(messages);
            }

            // 将TS的状态改成维修中
            TSFacade tsFacade = new TSFacade(this.DataProvider);
            object   obj      = tsFacade.GetCardLastTSRecord(actionEventArgs.LotCode);

            if (obj != null)
            {
                Domain.TS.TS ts = (Domain.TS.TS)obj;
                ts.ConfirmResourceCode = actionEventArgs.ResourceCode;
                ts.ConfirmUser         = actionEventArgs.UserCode;
                ts.ConfirmDate         = actionEventArgs.ProductInfo.NowSimulation.BeginDate;
                ts.ConfirmTime         = actionEventArgs.ProductInfo.NowSimulation.BeginTime;
                ts.TSStatus            = TSStatus.TSStatus_TS;
                tsFacade.UpdateTS(ts);
            }
            else
            {
                return(messages);
            }

            // 开始设置回流
            ActionFactory     actionFactory     = new ActionFactory(this.DataProvider);
            IAction           actionTSComplete  = actionFactory.CreateAction(ActionType.DataCollectAction_TSComplete);
            TSActionEventArgs tsactionEventArgs = new TSActionEventArgs(
                ActionType.DataCollectAction_TSComplete,
                actionEventArgs.LotCode,
                actionEventArgs.UserCode,
                actionEventArgs.ResourceCode,
                TSStatus.TSStatus_Reflow,
                actionEventArgs.ProductInfo.NowSimulation.MOCode,
                actionEventArgs.ProductInfo.NowSimulation.ItemCode,
                routeCode,
                op.OPCode,
                actionEventArgs.UserCode,
                null);

            tsactionEventArgs.RouteCode            = routeCode;
            tsactionEventArgs.IgnoreResourceInOPTS = true;

            messages.AddMessages(actionTSComplete.Execute(tsactionEventArgs));

            return(messages);
        }
Ejemplo n.º 2
0
        public Messages AutoGoMO(ActionEventArgs actionEventArgs, ActionCheckStatus actionCheckStatus)
        {
            Messages msg = new Messages();

            // 如果当前序列号是在制品,则不会做归属工单
            if (actionEventArgs.ProductInfo != null &&
                actionEventArgs.ProductInfo.LastSimulation != null &&
                actionEventArgs.ProductInfo.LastSimulation.IsComplete != "1")
            {
                return(msg);
            }

            DBDateTime dbDateTime;

            dbDateTime = FormatHelper.GetNowDBDateTime(DataProvider);

            string strResCode = actionEventArgs.ResourceCode;
            string strRCard   = actionEventArgs.LotCode;
            // 根据资源检查是否需要归属工单
            Resource2MO res2mo = GetResource2MOByResource(strResCode, dbDateTime);

            if (res2mo == null)         // 如果没有设置,表示不用归属工单,直接返回
            {
                return(msg);
            }
            // 检查序列号格式
            msg.AddMessages(CheckRCardFormatByResource2MO(res2mo, actionEventArgs.LotCode, actionEventArgs));
            if (msg.IsSuccess() == false)
            {
                return(msg);
            }
            // 解析工单
            string strMOCode = BuildMOCodeByResource2MO(res2mo, actionEventArgs.LotCode, actionEventArgs, dbDateTime);
            // 执行归属工单的操作
            GoToMOActionEventArgs gomoArg = new GoToMOActionEventArgs(ActionType.DataCollectAction_GoMO,
                                                                      actionEventArgs.LotCode,
                                                                      actionEventArgs.UserCode,
                                                                      actionEventArgs.ResourceCode,
                                                                      actionEventArgs.ProductInfo,
                                                                      strMOCode);
            IAction gomoAction = new ActionFactory(this.DataProvider).CreateAction(ActionType.DataCollectAction_GoMO);

            try
            {
                if (actionCheckStatus != null)
                {
                    msg.AddMessages(((IActionWithStatus)gomoAction).Execute(gomoArg, actionCheckStatus));
                }
                else
                {
                    msg.AddMessages(gomoAction.Execute(gomoArg));
                }
            }
            catch (Exception e)
            {
                msg.Add(new Message(e));
            }
            if (msg.IsSuccess() == true)
            {
                msg.Add(new UserControl.Message(MessageType.Success, "$CS_GOMOSUCCESS"));

                if (actionCheckStatus == null || actionCheckStatus.NeedUpdateSimulation == true)
                {
                    ActionOnLineHelper onLine     = new ActionOnLineHelper(this.DataProvider);
                    Messages           msgProduct = onLine.GetIDInfo(actionEventArgs.LotCode);
                    actionEventArgs.ProductInfo = (ProductInfo)msgProduct.GetData().Values[0];
                }
                else
                {
                    actionEventArgs.ProductInfo.LastSimulation   = new ExtendSimulation(gomoArg.ProductInfo.NowSimulation);
                    actionCheckStatus.ProductInfo.LastSimulation = actionEventArgs.ProductInfo.LastSimulation;
                }
            }

            return(msg);
        }