Пример #1
0
        public double GetScrapWeight(int plantID, int lineID, int shiftID, DateTime productionDate)
        {
            double returnValue = 0;

            Plant         plant      = _repository.Repository <Plant>().GetById(plantID);
            UnitOfMeasure defaultUom = plant.UnitOfMeasureDefaults.First(m => m.UnitOfMeasureType.Code == "W").UnitOfMeasure;

            ProdLine     line     = _repository.Repository <ProdLine>().GetById(lineID);
            ProdLineType lineType = _repository.Repository <ProdLineType>().GetById(line.LineTypeID);

            Application.UoMConversionService convert = new Application.UoMConversionService();
            double result = 100;

            /*
             * var result = _repository.Repository<TPOLineScrap>().GetAllBy(
             *              p => p.PlantID == plantID &&
             *                   p.ShiftID == shiftID &&
             *                   p.WorkOrder.LineID == lineID &&
             *                   p.ProductionDate == productionDate).Sum(
             *                      p => convert.ConvertUoM(p.WeightUoMID, (decimal)p.Weight, defaultUom.ID)
             *                   );
             *
             * returnValue = (double)Math.Round(result, 0);
             */
            returnValue = result;

            return(returnValue);
        }
Пример #2
0
        public double GetScrapPercent(int plantID, int lineID, int shiftID, DateTime productionDate)
        {
            double returnValue = 0;

            Plant         plant      = _repository.Repository <Plant>().GetById(plantID);
            UnitOfMeasure defaultUom = plant.UnitOfMeasureDefaults.First(m => m.UnitOfMeasureType.Code == "W").UnitOfMeasure;

            ProdLine        line     = _repository.Repository <ProdLine>().GetById(lineID);
            ProdLineType    lineType = _repository.Repository <ProdLineType>().GetById(line.LineTypeID);
            ProductionShift shift    = _repository.Repository <ProductionShift>().GetById(shiftID);

            Application.UoMConversionService convert = new Application.UoMConversionService();

            var scrap = 0;

            /*
             * var scrap = _repository.Repository<TPOLineScrap>().GetAllBy(
             *  p => p.PlantID == plantID &&
             *          p.ShiftID == shiftID &&
             *          p.WorkOrder.LineID == lineID &&
             *          p.ProductionDate == productionDate).Sum(
             *              p => convert.ConvertUoM(p.WeightUoMID, (decimal)p.Weight, defaultUom.ID)
             *          );
             */
            if (lineType.ProdLineTypeCode == "IM")
            {
                var prod = 0;

                /*
                 * var prod = _repository.Repository<IMProd>().GetAllBy(
                 *      p => p.ProdLineID == lineID &&
                 *              p.ProdShift == shift.Code &&
                 *              p.PlantID == plantID &&
                 *              p.ProdDate == productionDate).Sum(
                 *                  p => convert.ConvertUoM(p.WeightUOM, (decimal)p.CartonWeight, defaultUom.ID)
                 *              );
                 */
                if (prod > 0)
                {
                    returnValue = (double)(scrap / prod);
                }
            }
            else
            {
                var prod = 0;

                /*
                 * var prod = _repository.Repository<TPOCProductRoll>().GetAllBy(
                 *      p => p.LineID == lineID &&
                 *              p.ShiftID == shiftID &&
                 *              p.PlantID == plantID &&
                 *              p.ProductionDate == productionDate).Sum(
                 *                  p => convert.ConvertUoM(p.WeightUoMID, (decimal)p.Weight, defaultUom.ID)
                 *              );
                 */
                if (prod > 0)
                {
                    returnValue = (double)(scrap / prod);
                }
            }

            return(returnValue);
        }