コード例 #1
0
        public ActionResult Previsao(long?_id, string _tipo)
        {
            double?[] prev = new double?[2];

            List <CursoPrevisao> listaPrev = PrevisaoEmec.getPrevisao(this.Configuration);

            var query = listaPrev.Where(x => x.CodArea == _id).OrderBy(x => x.Ano).ToList();


            prev = GeraPrevisao(_id, _tipo, query);

            List <string> tipos = new List <string>()
            {
                "D", "R", "M"
            };

            if (tipos.Contains(_tipo.ToUpper()))
            {
                prev[0] = (prev[0] < 0) ? 0 : prev[0];
                prev[0] = (prev[0] > 5) ? 5 : prev[0];

                prev[1] = (prev[1] < 0) ? 0 : prev[1];
                prev[1] = (prev[1] > 5) ? 5 : prev[1];
            }


            return(Ok(prev));
        }
コード例 #2
0
        private Dictionary <long?, PrevisaoSKU> GeraListaPrevisaoSKU()
        {
            // if (ListaPrevisaoSKU != null)
            // {
            //     return;
            // }

            List <CursoPrevisao> listaPrev = PrevisaoEmec.getPrevisao(this.Configuration);

            Dictionary <long?, PrevisaoSKU> ListaPrevisaoSKU = new Dictionary <long?, PrevisaoSKU>();

            PrevisaoSKU prev;

            var areas = listaPrev.Select(x => x.CodArea).Distinct().ToList();

            foreach (var item in areas)
            {
                var query = listaPrev.Where(x => x.CodArea == item).ToList();
                var resM  = GeraPrevisao(item, "M", query);
                var resD  = GeraPrevisao(item, "D", query);
                var resR  = GeraPrevisao(item, "R", query);

                resM[0] = (resM[0] < 0) ? 0 : resM[0];
                resM[0] = (resM[0] > 1) ? 1 : resM[0];

                resM[1] = (resM[1] < 0) ? 0 : resM[1];
                resM[1] = (resM[1] > 1) ? 1 : resM[1];

                resD[0] = (resD[0] < 0) ? 0 : resD[0];
                resD[0] = (resD[0] > 1) ? 1 : resD[0];

                resD[1] = (resD[1] < 0) ? 0 : resD[1];
                resD[1] = (resD[1] > 1) ? 1 : resD[1];

                resR[0] = (resR[0] < 0) ? 0 : resR[0];
                resR[0] = (resR[0] > 1) ? 1 : resR[0];

                resR[1] = (resR[1] < 0) ? 0 : resR[1];
                resR[1] = (resR[1] > 1) ? 1 : resR[1];


                prev              = new PrevisaoSKU();
                prev.CodArea      = item;
                prev.P_Min_Mestre = resM[0];
                prev.P_Max_Mestre = resM[1];
                prev.P_Min_Doutor = resD[0];
                prev.P_Max_Doutor = resD[1];
                prev.P_Min_Regime = resR[0];
                prev.P_Max_Regime = resR[1];

                ListaPrevisaoSKU.Add(prev.CodArea, prev);
            }
            ;

            return(ListaPrevisaoSKU);
        }
コード例 #3
0
        public async Task <IActionResult> GeraNota(long?id)
        {
            List <CursoPrevisao> listaPrev = await Task.Run(() => {
                return(PrevisaoEmec.getPrevisao(this.Configuration));
            });

            var query = listaPrev.Where(x => x.CodArea == id).ToList();

            return(Ok(query));
        }