예제 #1
0
        private Domain.TS.TS GetNewTS(string runningCard, string partItemCode, string partRunningCard, string userCode)
        {
            SystemSettingFacade systemSettingFacade = new SystemSettingFacade(this.DataProvider);
            ShiftModelFacade    shiftModelFacade    = new ShiftModelFacade(this.DataProvider);
            ModelFacade         modelFacade         = new ModelFacade(this.DataProvider);
            TSFacade            tsFacade            = new TSFacade(this.DataProvider);
            DataCollectFacade   dataCollectFacade   = new DataCollectFacade(this.DataProvider);

            string sourceRCard = dataCollectFacade.GetSourceCard(runningCard.Trim().ToUpper(), string.Empty);

            DBDateTime       dbDateTime     = FormatHelper.GetNowDBDateTime(this.DataProvider);
            SimulationReport lastSimulation = dataCollectFacade.GetLastSimulationReport(sourceRCard);

            if (lastSimulation == null)
            {
                return(null);
            }

            Domain.TS.TS newTS = tsFacade.CreateNewTS();

            newTS.TSId                  = Guid.NewGuid().ToString();
            newTS.RunningCard           = partRunningCard;
            newTS.RunningCardSequence   = dataCollectFacade.GetMaxRCardSequenceFromTS(partRunningCard) + 100;
            newTS.TranslateCard         = partRunningCard;
            newTS.TranslateCardSequence = newTS.RunningCardSequence;
            newTS.SourceCard            = partRunningCard;
            newTS.SourceCardSequence    = newTS.RunningCardSequence;
            newTS.CardType              = CardType.CardType_Part;
            newTS.ReplacedRunningCard   = " ";

            newTS.ItemCode = partItemCode;
            Model model = (Model)modelFacade.GetModelByItemCode(partItemCode);

            if (model == null)
            {
                Parameter parameter = (Parameter)systemSettingFacade.GetParameter("PING", "DEFAULT_MODEL_CODE");
                if (parameter != null)
                {
                    newTS.ModelCode = parameter.ParameterAlias.Trim().ToUpper();
                }
            }
            else
            {
                newTS.ModelCode = model.ModelCode;
            }

            newTS.MOCode               = lastSimulation.MOCode;
            newTS.FromRouteCode        = lastSimulation.RouteCode;
            newTS.FromOPCode           = lastSimulation.OPCode;
            newTS.FromResourceCode     = lastSimulation.ResourceCode;
            newTS.FromSegmentCode      = lastSimulation.SegmentCode;
            newTS.FromStepSequenceCode = lastSimulation.StepSequenceCode;
            newTS.FromShiftTypeCode    = lastSimulation.ShiftTypeCode;
            newTS.MOSeq = lastSimulation.MOSeq;

            TimePeriod tp = (TimePeriod)shiftModelFacade.GetTimePeriod(newTS.FromShiftTypeCode, dbDateTime.DBTime);

            if (tp != null)
            {
                newTS.FromTimePeriodCode = tp.TimePeriodCode;
                newTS.FromShiftCode      = tp.ShiftCode;
                newTS.FromShiftDay       = shiftModelFacade.GetShiftDay(tp, dbDateTime.DateTime);
            }

            newTS.FromUser = userCode;
            newTS.FromDate = dbDateTime.DBDate;
            newTS.FormTime = dbDateTime.DBTime;

            newTS.MaintainUser = userCode;
            newTS.MaintainDate = dbDateTime.DBDate;
            newTS.MaintainTime = dbDateTime.DBTime;

            newTS.TSTimes           = tsFacade.GetMaxTSTimes(partRunningCard) + 1;
            newTS.FromInputType     = TSSource.TSSource_TS;
            newTS.TSStatus          = TSStatus.TSStatus_New;
            newTS.TransactionStatus = TransactionStatus.TransactionStatus_NO;

            return(newTS);
        }