Пример #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).ErrorInfor != null)
            {
                TSErrorCode2Location[] error = new TSErrorCode2Location[((TSActionEventArgs)actionEventArgs).ErrorInfor.Length];
                ((TSActionEventArgs)actionEventArgs).ErrorInfor.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);
                    }
                }
            }
            else 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.RunningCard);

            if (obj != null)
            {
                Domain.TS.TS ts = (Domain.TS.TS)obj;
                ts.ConfirmResourceCode = actionEventArgs.ResourceCode;
                ts.ConfirmUser         = actionEventArgs.UserCode;
                ts.ConfirmDate         = actionEventArgs.ProductInfo.NowSimulation.MaintainDate;
                ts.ConfirmTime         = actionEventArgs.ProductInfo.NowSimulation.MaintainTime;
                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.RunningCard,
                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);
        }
Пример #2
0
        public override Messages Action(object act)
        {
            Messages msg = new Messages();

            BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider domainProvider = null;


            if (act == null)
            {
                return(msg);
            }

            if ((act as IDCTClient).DBConnection != null)
            {
                domainProvider = (act as IDCTClient).DBConnection as BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider;
            }
            else
            {
                domainProvider = Common.DomainDataProvider.DomainDataProviderManager.DomainDataProvider()
                                 as BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider;
                (act as IDCTClient).DBConnection = domainProvider;
            }


            if (m_FlowControl == 1)
            {
                string itemCode = ((Item)_item).ItemCode.ToString();
                strCarton = act.ToString().Trim().ToUpper();

                if (((Item)_item).NeedCheckCarton == FormatHelper.TRUE_STRING)
                {
                    if (strRcard.StartsWith(itemCode, StringComparison.CurrentCultureIgnoreCase))
                    {
                        if (string.Compare(strRcard, strCarton, true) == 0)
                        {
                            msg.Add(new UserControl.Message(MessageType.Error, "$Error_CartonNotMatchTheRule"));
                            msg.Add(new UserControl.Message(MessageType.Success, "$CS_PLEASE_INPUT_CARTONNO"));

                            this.Status = ActionStatus.PrepareData;
                            return(msg);
                        }
                        else
                        {
                            if (string.Compare(strRcard.Replace(" ", ""), strCarton.Replace(" ", ""), true) != 0)
                            {
                                msg.Add(new UserControl.Message(MessageType.Error, "$Error_CartonCheckFailed"));
                                msg.Add(new UserControl.Message(MessageType.Success, "$CS_PLEASE_INPUT_CARTONNO"));
                                this.Status = ActionStatus.PrepareData;
                                return(msg);
                            }
                            else
                            {
                                msg.Add(new UserControl.Message(MessageType.Success, "$CARTON_COMPARE_ISSUCCESS"));
                            }
                        }
                    }
                    else
                    {
                        if (string.Compare(strRcard, strCarton, true) == 0)
                        {
                            msg.Add(new UserControl.Message(MessageType.Success, "$CARTON_COMPARE_ISSUCCESS"));
                        }
                        else
                        {
                            msg.Add(new UserControl.Message(MessageType.Error, "$Error_CartonCheckFailed"));
                            msg.Add(new UserControl.Message(MessageType.Success, "$CS_PLEASE_INPUT_CARTONNO"));
                            this.Status = ActionStatus.PrepareData;
                            return(msg);
                        }
                    }
                }

                object obj = (new Package.PackageFacade(domainProvider)).GetCARTONINFO(act.ToString().Trim().ToUpper());
                if (obj != null && ((CARTONINFO)obj).CAPACITY.ToString() == ((CARTONINFO)obj).COLLECTED.ToString())
                {
                    msg.Add(new UserControl.Message(MessageType.Error, "$CARTON_ALREADY_FILL_OUT"));
                    msg.Add(new UserControl.Message(MessageType.Success, "$CS_PLEASE_INPUT_CARTONNO"));
                    this.Status = ActionStatus.PrepareData;
                    return(msg);
                }
                else
                {
                    m_FlowControl++;
                    msg.Add(new UserControl.Message(MessageType.Normal, "$CS_PLEASE_INPUT_WRAPPER"));
                    this.Status = ActionStatus.PrepareData;
                    return(msg);
                }
            }
            else
            {
                //if (((Simulation)_objSimulation).ItemCode.ToUpper().Trim() == act.ToString().ToUpper())
                if (((Simulation)_objSimulation).RunningCard.ToUpper().IndexOf(act.ToString().ToUpper()) == 0)
                {
                    ActionOnLineHelper actionOnLineHelper = new ActionOnLineHelper(domainProvider);
                    BenQGuru.eMES.DataCollect.Action.ActionFactory actionFactory = new BenQGuru.eMES.DataCollect.Action.ActionFactory(domainProvider);
                    IAction actionCartonPack = actionFactory.CreateAction(ActionType.DataCollectAction_Carton);
                    //((BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider)domainProvider).PersistBroker.OpenConnection();
                    msg = actionOnLineHelper.GetIDInfo(strRcard);
                    string     cartonno = FormatHelper.CleanString(strCarton);
                    IDCTClient client   = act as IDCTClient;

                    //add by hiro 08/09/28
                    DBDateTime dbDateTime;
                    dbDateTime = FormatHelper.GetNowDBDateTime(domainProvider);
                    PackageFacade _Packfacade     = new PackageFacade(domainProvider);
                    PACKINGCHK    newPackingCheck = _Packfacade.CreateNewPACKINGCHK();
                    newPackingCheck.Rcard            = ((Simulation)_objSimulation).RunningCard.ToString().ToUpper();
                    newPackingCheck.CheckAccessory   = FormatHelper.TRUE_STRING;
                    newPackingCheck.CheckProductCode = FormatHelper.FALSE_STRING;
                    newPackingCheck.MUSER            = (act as IDCTClient).LoginedUser;
                    newPackingCheck.MDATE            = dbDateTime.DBDate;
                    newPackingCheck.MTIME            = dbDateTime.DBTime;
                    newPackingCheck.EATTRIBUTE1      = " ";
                    object objGet = _Packfacade.GetPACKINGCHK(((Simulation)_objSimulation).RunningCard.ToString().ToUpper());
                    if (objGet != null)
                    {
                        _Packfacade.DeletePACKINGCHK((PACKINGCHK)objGet);
                        _Packfacade.AddPACKINGCHK(newPackingCheck);
                    }
                    else
                    {
                        _Packfacade.AddPACKINGCHK(newPackingCheck);
                    }
                    //end by hiro

                    Messages msgTwo = new Messages();
                    domainProvider.BeginTransaction();
                    try
                    {
                        if (msg.IsSuccess())
                        {
                            ProductInfo product = (ProductInfo)msg.GetData().Values[0];
                            if (product.LastSimulation == null)
                            {
                                base.Action(act);
                                msgTwo.Add(new UserControl.Message(new Exception("$Error_LastSimulation_IsNull!")));
                                this.ObjectState = null;
                                return(msgTwo);
                            }

                            CartonPackEventArgs cartonPackEventArgs = new CartonPackEventArgs(ActionType.DataCollectAction_Carton,
                                                                                              strRcard, client.LoginedUser,
                                                                                              client.ResourceCode,
                                                                                              "",
                                                                                              cartonno,
                                                                                              product);

                            msgTwo.AddMessages(actionCartonPack.Execute(cartonPackEventArgs));
                        }
                        if (msgTwo.IsSuccess())
                        {
                            domainProvider.CommitTransaction();
                        }
                        else
                        {
                            domainProvider.RollbackTransaction();
                            msgTwo.Add(new UserControl.Message(MessageType.Normal, "$CS_Please_Input_RunningCard"));
                            this.Status      = ActionStatus.PrepareData;
                            this.FlowDirect  = FlowDirect.WaitingInput;
                            this.ObjectState = null;
                            this.clearValue();
                            return(msgTwo);
                        }
                    }
                    catch (Exception ex)
                    {
                        domainProvider.RollbackTransaction();
                        msg.Add(new UserControl.Message(ex));
                        msg.Add(new UserControl.Message(MessageType.Normal, "$CS_Please_Input_RunningCard"));
                        this.Status      = ActionStatus.PrepareData;
                        this.FlowDirect  = FlowDirect.WaitingInput;
                        this.ObjectState = null;
                        this.clearValue();
                        return(msg);
                    }
                    finally
                    {
                        ((BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider)domainProvider).PersistBroker.CloseConnection();
                    }

                    base.Action(act);
                    msg.Add(new UserControl.Message(MessageType.Success, "$CS_COMPAREAPPENDIX_SUCCESS"));
                    msg.Add(new UserControl.Message(MessageType.Success, "$CS_RCARD_CARTON_SUCCESS [" + strCarton + "]"));
                    this.ObjectState = null;
                    this.clearValue();
                    return(msg);
                }
                else
                {
                    msg.Add(new UserControl.Message(MessageType.Error, "$CS_COMPAREAPPENDIX_NOTSUCCESS"));
                    msg.Add(new UserControl.Message(MessageType.Normal, "$CS_PLEASE_INPUT_WRAPPER"));
                    this.Status = ActionStatus.PrepareData;
                    return(msg);
                }
            }
        }