Example #1
0
        public async Task <List <MessageCalculates> > Calculates(int productionOrderId, double furnaceQuantity, Analysis analysis, bool ajuste)
        {
            List <MessageCalculates> messages     = new List <MessageCalculates> ();
            List <string>            stringReturn = new List <string> ();
            var productionOrder = await GetProductionOrder(productionOrderId);

            if (productionOrder == null)
            {
                MessageCalculates message = new MessageCalculates();
                message.key   = "Ordem não encontrada";
                message.value = "Ordem não encontrada";
                messages.Add(message);
            }
            else
            {
                var productionOrderQuality = await _productionOrderQualityService.GetProductionOrder(productionOrder.productionOrderId);

                if (productionOrderQuality == null)
                {
                    productionOrderQuality = await _productionOrderQualityService.AddProductionOrderQuality(productionOrder);
                }

                messages.AddRange(await CalculatesAnalysis(analysis, productionOrder, furnaceQuantity, productionOrderQuality, ajuste));

                if (!ajuste)
                {
                    productionOrderQuality.calculateInitial = messages;
                    await _productionOrderQualityService.updateProductionOrderQuality(productionOrderQuality.productionOrderQualityId, productionOrderQuality);
                }
            }
            return(messages);
        }
Example #2
0
        public async Task <Analysis> AddAnalysis(int productionOrderId, Analysis analysis)
        {
            analysis.datetime = DateTime.Now.Ticks;
            var username          = analysis.username.ToString();
            var productionQuality = await _productionOrderQualityService.GetProductionOrder(productionOrderId);

            if (productionQuality.Analysis.Count <= 0)
            {
                productionQuality.Analysis = new List <Analysis>();
            }

            analysis.number = productionQuality.Analysis.Count + 1;

            // Espaço para os cálculos
            var(returnSpecification, messages) = await RecipeSpecification(analysis, productionQuality.productionOrderId
                                                                           , productionQuality.qntForno);

            if (returnSpecification)
            {
                analysis.status = "approved";
            }
            else
            {
                analysis.status = "reproved";
            }

            analysis.messages = messages;
            productionQuality.calculateInitial    = messages;
            productionQuality.CobreFosforosoAtual = analysis.cobreFosforoso;
            // Fim

            var returnApi = await PutStatusAnalysisForProductionOrder(productionQuality.productionOrderId, analysis.status, username);

            if (returnApi)
            {
                productionQuality.status = analysis.status;

                //insere o usuario na análise
                if (analysis.username == null)
                {
                    productionQuality.username = "******";
                }

                productionQuality.username = analysis.username;

                Console.WriteLine("Saving - printing analysis: ");
                Console.WriteLine(analysis.ToString());

                productionQuality.Analysis.Add(analysis);

                await _context.SaveChangesAsync();

                return(analysis);
            }
            Console.WriteLine("Não foi possivel alterar o status da ordem de produção");
            return(null);
        }
Example #3
0
        public async Task <IActionResult> GetProductionOrderId(int productionOrderId)
        {
            try {
                var productionQuality = await _productionOrderQualityService
                                        .GetProductionOrder(productionOrderId);

                if (productionQuality == null)
                {
                    return(NotFound());
                }

                return(Ok(productionQuality));
            } catch (Exception ex) {
                return(StatusCode(500, ex.Message));
            }
        }