Exemple #1
0
        public ReworkProductionEntryDto EnterReworkProduct(ReworkProductionEntryDto input)
        {
            bool   proceed = true;
            string message = string.Empty;

            if (!input.StartRoll2ID.HasValue)
            {
                proceed = CheckReworkEntry(input, out message);
            }
            if (proceed)
            {
                if (!string.IsNullOrEmpty(input.RollIn))
                {
                    #warning There are calls out to the archive tables in the old version of this code
                    var rollCount = _repository.Repository <TPOCProductRoll>().GetAllBy(r => r.Code == input.RollIn).Count();
                    if (rollCount > 0)
                    {
                        proceed = false;
                        message = string.Format("Roll number {0} already in use.", input.RollIn);
                    }
                }
            }
            if (proceed)
            {
                var lineDto     = (new TPO.Services.Production.ProductionLineService()).Get(input.LineID);
                var lineTypeDTO = (new TPO.Services.Production.ProdLineTypeService()).Get(lineDto.LineTypeID);

                //Create TPOCProductRoll record
                TPOCProductRollDto cRollDto = new TPOCProductRollDto();
                cRollDto.ProductionDate = input.ProductionDate;
                cRollDto.WorkOrderID    = lineDto.CurrentWorkOrderID.HasValue ? lineDto.CurrentWorkOrderID.Value : 0;
                cRollDto.LengthUoMID    = input.LengthUoMID;
                cRollDto.WeightUoMID    = input.WeightUoMID;
                cRollDto.ProductID      = input.TPOProductID;

                TPO.Services.Products.TPOCProductRollService cProdSvc = new Products.TPOCProductRollService();
                if (string.IsNullOrEmpty(input.RollIn))
                {
                    input.RollIn = cProdSvc.GetNewRollOrCartonCode(cRollDto, lineDto, lineTypeDTO);
                }
                cRollDto.BatchNumber  = cProdSvc.GetBatchNumber(cRollDto);
                cRollDto.DateEntered  = DateTime.Now;
                cRollDto.EnteredBy    = input.EnteredBy;
                cRollDto.LastModified = cRollDto.DateEntered;
                cRollDto.ModifiedBy   = cRollDto.EnteredBy;

                cRollDto.ID = cProdSvc.Add(cRollDto);

                TPOReworkAction action = new TPOReworkAction()
                {
                    LineID         = input.LineID,
                    ProductionDate = input.ProductionDate,
                    ShiftID        = input.ShiftID,
                    StartRollID    = input.StartRollID,
                    StartRoll2ID   = input.StartRoll2ID,
                    OutputRollID   = cRollDto.ID,
                    TypeID         = input.RWType,
                    Width          = input.Width,
                    WidthUoMID     = input.WidthUoMID,
                    Length         = input.Length,
                    LengthUoMID    = input.LengthUoMID,
                    Weight         = input.Weight,
                    WeightUoMID    = input.WeightUoMID,
                    Comments       = input.Comments,
                    DateEntered    = cRollDto.DateEntered,
                    EnteredBy      = cRollDto.EnteredBy,
                    LastModified   = cRollDto.DateEntered,
                    ModifiedBy     = cRollDto.EnteredBy,
                    PlantID        = input.PlantID
                };

                if (cProdSvc.IsFlashingMasterRoll(cRollDto))
                {
                    cProdSvc.AddToReworkList(cRollDto);
                }
                using (TPOReworkRollService rwRollSvc = new TPOReworkRollService())
                {
                    rwRollSvc.CheckRollProcessed(input.StartRollID);
                    if (input.StartRoll2ID.HasValue)
                    {
                        rwRollSvc.CheckRollProcessed(input.StartRoll2ID.Value);
                    }
                }

                //TODO: Print label
            }
            input.Message = message;
            return(input);
        }
Exemple #2
0
        public ReworkProductionEntryDto EnterReworkScrap(ReworkProductionEntryDto input)
        {
            bool   proceed = true;
            string message = string.Empty;

            if (!input.StartRoll2ID.HasValue)
            {
                proceed = CheckReworkEntry(input, out message);
            }
            if (proceed)
            {
                TPOReworkRollService rwRollSvc = new TPOReworkRollService();

                //Get prodLine
                var prodLine = _repository.Repository <ProdLine>().GetById(input.LineID);

                //Get master roll, if any
                TPO.Services.Products.TPOCProductRollService cProdRollSvc = new Products.TPOCProductRollService();
                var masterRoll   = cProdRollSvc.GetMasterRollByCode(input.RollIn);
                int?masterRollID = masterRoll != null ? masterRoll.ID : (int?)null;

                //Get scrap id
                TPO.Services.Scrap.TPOLineScrapService tpoScrapSvc = new Scrap.TPOLineScrapService();
                string scrapId = tpoScrapSvc.GetNewScrapCode(input.LineID, input.ProductionDate);

                //Get batch number
                TPO.Services.Production.TPOBatchService batchSvc = new Production.TPOBatchService();
                int batchNumber = batchSvc.GetTPOProdBatchNumber(input.LineID, input.TPOProductID, input.EnteredBy, masterRollID);

                //Get scrap code from TPOLineScrap
                var    lineScraps = tpoScrapSvc.GetByReworkRollID(input.StartRollID);
                string scrapCode  = lineScraps != null && lineScraps.Count > 0  ? lineScraps[0].ScrapCode : "11e";


                var             now         = DateTime.Now;
                TPOLineScrapDto newScrapDto = new TPOLineScrapDto()
                {
                    Code           = scrapId,
                    ProductionDate = input.ProductionDate,
                    ShiftID        = input.ShiftID,
                    BatchNumber    = batchNumber,
                    Length         = input.Length,
                    LengthUoMID    = input.LengthUoMID,
                    Weight         = input.Weight,
                    WeightUoMID    = input.WeightUoMID,
                    Width          = input.Width,
                    WidthUoMID     = input.WidthUoMID,
                    TypeID         = input.RWType,
                    Comment        = input.Comments,
                    WorkOrderID    = prodLine.CurrentWorkOrderID.Value,
                    PlantID        = input.PlantID,
                    DateEntered    = now,
                    EnteredBy      = input.EnteredBy,
                    LastModified   = now,
                    ModifiedBy     = input.EnteredBy
                };
                newScrapDto.ID = tpoScrapSvc.Add(newScrapDto);

                TPOReworkActionDto actionDto = new TPOReworkActionDto()
                {
                    LineID         = input.LineID,
                    ProductionDate = input.ProductionDate,
                    ShiftID        = input.ShiftID,
                    StartRollID    = input.StartRollID,
                    StartRoll2ID   = input.StartRoll2ID,
                    OutputRollID   = masterRollID,
                    NewProductID   = input.TPOProductID,
                    TypeID         = input.RWType,
                    Weight         = input.Weight,
                    WeightUoMID    = input.WeightUoMID,
                    Width          = input.Width,
                    WidthUoMID     = input.WidthUoMID,
                    Length         = input.Length,
                    LengthUoMID    = input.LengthUoMID,
                    DateEntered    = now,
                    EnteredBy      = input.EnteredBy,
                    OutputScrapID  = newScrapDto.ID
                };


                actionDto.ID = Add(actionDto);

                if (input.StartRoll2ID.HasValue)
                {
                    rwRollSvc.CheckRollProcessed(input.StartRoll2ID.Value);
                }
                if (input.RWType == 2)
                {
                    //If scrap type 2, enter roll into rework table
                    TPOReworkRollDto rwRollDto = new TPOReworkRollDto()
                    {
                        Code         = scrapId,
                        LineID       = input.LineID,
                        TPOProductID = input.TPOProductID,
                        ShiftID      = input.ShiftID,
                        Length       = input.Length,
                        LengthUoMID  = input.LengthUoMID,
                        DateEntered  = now,
                        EnteredBy    = input.EnteredBy,
                        LastModified = now,
                        ModifiedBy   = input.EnteredBy
                    };
                    rwRollDto.ID = rwRollSvc.Add(rwRollDto);
                }
                if (input.RWType == 3)
                {
                    //If scrap type 3, add roll into reclaim wip

                    TPO.Services.Reclaim.TPOReclaimActionService rcActionSvc = new Reclaim.TPOReclaimActionService();
                    rcActionSvc.EnterReclaimScrap(input.PlantID, input.LineID, input.TPOProductID, input.Weight, input.ProductionDate, scrapId, input.EnteredBy);
                }

                //TODO:  Print label
            }
            input.Message = message;
            return(input);
        }