private async Task <ProductionOrder> ProductionOrderReport(int productionOrderId)
        {
            ProductionOrder productionOrder = null;

            productionOrder = _productionOrderList.Where(x => x.productionOrderId == productionOrderId).FirstOrDefault();

            if (productionOrder == null)
            {
                productionOrder = await _otherAPIService.GetProductionOrderPerId(productionOrderId);

                if (productionOrder != null)
                {
                    _productionOrderList.Add(productionOrder);
                }
            }
            return(productionOrder);
        }
예제 #2
0
        public async Task <(Report, string)> GetReportPerRecipeCode(string recipeCode, int thingId, long startDate, long endDate)
        {
            Report reportReturn = new Report();

            reportReturn.tags = new List <Tag>();

            if (endDate <= 0)
            {
                endDate = 999999999999999999;
            }

            var productionOrderIds = await _otherAPIService.GetHistStateProductionOrderList("active", startDate, endDate);

            if (productionOrderIds.Count() == 0)
            {
                return(null, "Not found ProductionOrders");
            }

            foreach (var productionOrderId in productionOrderIds)
            {
                var productionOrder = await _otherAPIService.GetProductionOrderPerId(productionOrderId);

                if (productionOrder.recipe.recipeCode.ToLower() == recipeCode.ToLower())
                {
                    var(report, stringErro) = await AddReportPeriod(reportReturn, productionOrder.productionOrderId, thingId);

                    if (report == null)
                    {
                        return(null, stringErro);
                    }

                    reportReturn = report;
                }
            }

            return(SetColorTags(reportReturn), string.Empty);
        }