protected object GetObject(string list)
        {
            if (facade == null)
            {
                facade = new TSModelFacade(this.DataProvider);
            }

            object obj = this.facade.GetErrorCode2OPRework(this.txtOPCodeQuery.Text, list, GlobalVariables.CurrentOrganizations.First().OrganizationID);

            if (obj != null)
            {
                WebInfoPublish.Publish(this, list + "$Error_Primary_Key_Overlap", this.languageComponent1);
                return(null);
            }

            ErrorCode2OPRework errorCode2OPRework = facade.CreateNewErrorCode2OPRework();

            errorCode2OPRework.OPCode         = FormatHelper.PKCapitalFormat(FormatHelper.CleanString(this.txtOPCodeQuery.Text));
            errorCode2OPRework.ErrorCode      = FormatHelper.PKCapitalFormat(FormatHelper.CleanString(list));
            errorCode2OPRework.RouteCode      = FormatHelper.CleanString(this.txtReworkRoute.Text);
            errorCode2OPRework.ToOPCode       = FormatHelper.CleanString(this.txtReworkOPCode.Text);
            errorCode2OPRework.MaintainUser   = this.GetUserCode();
            errorCode2OPRework.OrganizationID = GlobalVariables.CurrentOrganizations.First().OrganizationID;

            return(errorCode2OPRework);
        }
        protected override object GetEditObject()
        {
            if (facade == null)
            {
                facade = new TSModelFacade(this.DataProvider);
            }

            ErrorCode2OPRework errorCode2OPRework = facade.CreateNewErrorCode2OPRework();

            errorCode2OPRework.OPCode         = FormatHelper.PKCapitalFormat(FormatHelper.CleanString(this.txtOPCodeQuery.Text));
            errorCode2OPRework.ErrorCode      = FormatHelper.PKCapitalFormat(FormatHelper.CleanString(this.txtErrorCode.Text));
            errorCode2OPRework.RouteCode      = FormatHelper.CleanString(this.txtReworkRoute.Text);
            errorCode2OPRework.ToOPCode       = FormatHelper.CleanString(this.txtReworkOPCode.Text);
            errorCode2OPRework.MaintainUser   = this.GetUserCode();
            errorCode2OPRework.OrganizationID = GlobalVariables.CurrentOrganizations.First().OrganizationID;

            return(errorCode2OPRework);
        }
Exemple #3
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);
        }