Пример #1
0
        protected override object GetEditObject(UltraGridRow row)
        {
            if (_facade == null)
            {
                _facade = new ReworkFacadeFactory(base.DataProvider).Create();
            }
            ReworkRange reworkRange = this._facade.CreateNewReworkRange();

            reworkRange.ReworkCode   = this.txtReworkSheetCode.Text;
            reworkRange.RunningCard  = GetText(row.Cells[1].Text);
            reworkRange.MaintainUser = this.GetUserCode();
            try
            {
                reworkRange.RunningCardSequence = decimal.Parse(row.Cells[2].Text);
            }
            catch
            {
                ExceptionManager.Raise(this.GetType(), "$Error_Format");
//                throw new Exception(ErrorCenter.GetErrorUserDescription( this.GetType().BaseType, string.Format(ErrorCenter.ERROR_FORMAT, "RunningCardSequence") ) );
            }
            return(reworkRange);
        }
Пример #2
0
        public Messages GenerateLot(ActionEventArgs actionEventArgs)
        {
            Messages         messages         = new Messages();
            DataCollectDebug dataCollectDebug = new DataCollectDebug(this.GetType().ToString() + "Collect");

            dataCollectDebug.WhenFunctionIn(messages);

            try
            {
                string itemCode = actionEventArgs.ProductInfo.NowSimulation.ItemCode;
                string rCard    = actionEventArgs.ProductInfo.NowSimulation.RunningCard;
                string moCode   = actionEventArgs.ProductInfo.NowSimulation.MOCode;

                ItemFacade      itemFacade      = new ItemFacade(this.DataProvider);
                BaseModelFacade baseModelFacade = new BaseModelFacade(this.DataProvider);
                OQCFacade       oqcFacade       = new OQCFacade(this.DataProvider);

                object item = itemFacade.GetItem(itemCode, GlobalVariables.CurrentOrganizations.First().OrganizationID);
                if (item == null)
                {
                    messages.Add(new Message(MessageType.Error, "$Error_ItemCode_NotExist $Domain_ItemCode=" + itemCode));
                    return(messages);
                }
                //if (((Item)item).CheckItemOP == null || ((Item)item).CheckItemOP.Trim().Length == 0)
                //{
                //    messages.Add(new Message(MessageType.Error, "$Error_NoItemGenerateLotOPCode $Domain_ItemCode=" + itemCode));
                //    return messages;
                //}

                DBDateTime currentDBDateTime = FormatHelper.GetNowDBDateTime(this.DataProvider);
                OQCLot     lot;

                // Resource auto generate lotno for ReworkSheet
                Resource res = actionEventArgs.ProductInfo.Resource;
                if (res == null)
                {
                    res = (Resource)baseModelFacade.GetResource(actionEventArgs.ResourceCode);
                    actionEventArgs.ProductInfo.Resource = res;
                }

                ReworkFacade reworkFacade = new ReworkFacade(this.DataProvider);
                ReworkRange  reworkRange  = null;
                OQCLot       currentLot   = (OQCLot)oqcFacade.GetLatestOQCLot(actionEventArgs.RunningCard);
                if (currentLot != null && currentLot.LOTStatus == OQCLotStatus.OQCLotStatus_Reject)
                {
                    reworkRange = (ReworkRange)reworkFacade.GetLatestReworkRange(actionEventArgs.RunningCard);
                }

                //产生新批的情况有两种
                //情况一:返工Res(Res.ReworkRouteCode不为空),RCard有当前的返工需求单,且此返工需求单要求自动产生新批(ReworkSheet.AutoLot等于Y)
                //情况二:其他情况,当前工序为Item的产生批工序(当前工序等于Item.CheckItemOP)
                //
                if (res != null && res.ReworkRouteCode != null && res.ReworkRouteCode.Trim().Length > 0 &&
                    reworkRange != null && reworkRange.ReworkCode != null && reworkRange.ReworkCode.Trim().Length > 0)
                {
                    object      reworkSheet = reworkFacade.GetReworkSheet(reworkRange.ReworkCode);
                    ReworkSheet rs          = reworkSheet as ReworkSheet;

                    if (rs.AutoLot != null && string.Compare(rs.AutoLot, "Y", true) == 0 &&
                        rs.LotList != null && rs.LotList.Trim().Length > 0)
                    {
                        //Get rework lot by oldlotno (reworkcode=oldlotno=lotlist)
                        object rLot = oqcFacade.GetOQCLotByOldLotNo(rs.LotList);
                        if (rLot == null)
                        {
                            lot = this.CreateNewLot(actionEventArgs, (Item)item, currentDBDateTime, true, rs.LotList);
                        }
                        else
                        {
                            lot = rLot as OQCLot;
                        }
                    }
                    else
                    {
                        return(messages);
                    }
                }
                else
                {
                    if (string.Compare(((Item)item).CheckItemOP, actionEventArgs.ProductInfo.NowSimulation.OPCode, true) != 0)
                    {
                        return(messages);
                    }

                    // GetLot2Card By RCard+LotStatus
                    if (oqcFacade.IsCardUsedByAnyLot(rCard, moCode, itemCode))
                    {
                        return(messages);
                    }
                    else
                    {
                        lot = this.CreateNewLot(actionEventArgs, (Item)item, currentDBDateTime, false, "");
                    }
                }

                object oldLot2Card = oqcFacade.GetOQCLot2Card(actionEventArgs.ProductInfo.NowSimulation.RunningCard,
                                                              actionEventArgs.ProductInfo.NowSimulation.MOCode, lot.LOTNO, lot.LotSequence);
                if (oldLot2Card != null)
                {
                    //messages.Add(new Message(MessageType.Error, "$Error_IDHasExistedInOtherOQCLotNO $CS_LotNo=" + lot.LOTNO));
                    return(messages);
                }

                actionEventArgs.ProductInfo.NowSimulation.LOTNO       = lot.LOTNO;
                actionEventArgs.ProductInfo.NowSimulationReport.LOTNO = lot.LOTNO;
                DataCollectFacade dataCollect = new DataCollectFacade(this.DataProvider);
                dataCollect.UpdateSimulation(actionEventArgs.ProductInfo.NowSimulation);
                dataCollect.UpdateSimulationReport(actionEventArgs.ProductInfo.NowSimulationReport);

                OQCLot2Card oqcLot2Card = oqcFacade.CreateNewOQCLot2Card();
                oqcLot2Card.ItemCode            = actionEventArgs.ProductInfo.NowSimulation.ItemCode;
                oqcLot2Card.CollectType         = "pcs";
                oqcLot2Card.LOTNO               = lot.LOTNO;
                oqcLot2Card.LotSequence         = OQCFacade.Lot_Sequence_Default;
                oqcLot2Card.MaintainUser        = actionEventArgs.UserCode;
                oqcLot2Card.MaintainDate        = currentDBDateTime.DBDate;
                oqcLot2Card.MaintainTime        = currentDBDateTime.DBTime;
                oqcLot2Card.MOCode              = actionEventArgs.ProductInfo.NowSimulation.MOCode;
                oqcLot2Card.ModelCode           = actionEventArgs.ProductInfo.NowSimulation.ModelCode;
                oqcLot2Card.OPCode              = actionEventArgs.ProductInfo.NowSimulation.OPCode;
                oqcLot2Card.ResourceCode        = actionEventArgs.ProductInfo.NowSimulation.ResourceCode;
                oqcLot2Card.RouteCode           = actionEventArgs.ProductInfo.NowSimulation.RouteCode;
                oqcLot2Card.RunningCard         = actionEventArgs.ProductInfo.NowSimulation.RunningCard;
                oqcLot2Card.RunningCardSequence = actionEventArgs.ProductInfo.NowSimulation.RunningCardSequence;
                oqcLot2Card.SegmnetCode         = actionEventArgs.ProductInfo.NowSimulationReport.SegmentCode;
                oqcLot2Card.ShiftCode           = actionEventArgs.ProductInfo.NowSimulationReport.ShiftCode;
                oqcLot2Card.ShiftTypeCode       = actionEventArgs.ProductInfo.NowSimulationReport.ShiftTypeCode;
                oqcLot2Card.Status              = actionEventArgs.ProductInfo.NowSimulationReport.Status;
                oqcLot2Card.StepSequenceCode    = actionEventArgs.ProductInfo.NowSimulationReport.StepSequenceCode;
                oqcLot2Card.TimePeriodCode      = actionEventArgs.ProductInfo.NowSimulationReport.TimePeriodCode;
                //oqcLot2Card.EAttribute1 = actionEventArgs.ProductInfo.NowSimulation.CartonCode;
                oqcLot2Card.EAttribute1 = ""; //现在这里只能是空,后面Carton包装时候会更新为CartonCode
                oqcLot2Card.MOSeq       = actionEventArgs.ProductInfo.NowSimulation.MOSeq;

                oqcFacade.AddOQCLot2Card(oqcLot2Card);

                // Added By Hi1/Venus.Feng on 20081027 for Hisense Version : Add Frozen by lot logic
                if (lot.FrozenStatus == FrozenStatus.STATUS_FRONZEN)
                {
                    Frozen frozen = new Frozen();
                    frozen.RCard        = actionEventArgs.ProductInfo.NowSimulation.RunningCard;
                    frozen.EAttribute1  = "";
                    frozen.FrozenBy     = lot.FrozenBy;
                    frozen.FrozenDate   = lot.FrozenDate;
                    frozen.FrozenReason = lot.FrozenReason;

                    int      seq            = 0;
                    object[] oldFrozenRCard = oqcFacade.QueryFrozen(frozen.RCard, frozen.RCard,
                                                                    string.Empty, string.Empty, string.Empty, string.Empty,
                                                                    -1, -1, -1, -1, int.MinValue, int.MaxValue);

                    if (oldFrozenRCard != null)
                    {
                        foreach (Frozen f in oldFrozenRCard)
                        {
                            seq = Math.Max(seq, f.FrozenSequence);
                        }
                    }

                    frozen.FrozenSequence = seq + 1;
                    frozen.FrozenStatus   = FrozenStatus.STATUS_FRONZEN;
                    frozen.FrozenTime     = lot.FrozenTime;
                    frozen.ItemCode       = actionEventArgs.ProductInfo.NowSimulation.ItemCode;
                    frozen.LotNo          = lot.LOTNO;
                    frozen.LotSequence    = Convert.ToInt32(lot.LotSequence);
                    frozen.MaintainDate   = currentDBDateTime.DBDate;
                    frozen.MaintainTime   = currentDBDateTime.DBTime;
                    frozen.MaintainUser   = actionEventArgs.UserCode;
                    frozen.MOCode         = actionEventArgs.ProductInfo.NowSimulation.MOCode;
                    frozen.ModelCode      = actionEventArgs.ProductInfo.NowSimulation.ModelCode;
                    frozen.UnfrozenBy     = "";
                    frozen.UnfrozenDate   = 0;
                    frozen.UnfrozenReason = "";
                    frozen.UnfrozenTime   = 0;

                    oqcFacade.AddFrozen(frozen);
                }
                // End Added

                //Update tbloqclot.lotsize++
                lot.LotSize = 1;
                oqcFacade.UpdateOQCLotSize(lot);
            }
            catch (Exception ex)
            {
                messages.Add(new Message(ex));
            }
            dataCollectDebug.WhenFunctionOut(messages);
            return(messages);
        }