Ejemplo n.º 1
0
 public async Task <List <MixingInfoDto> > GetMixingInfoByGlueName(string glueName)
 {
     return(await _repoMixingInfor.FindAll().Include(x => x.Glue).Where(x => x.GlueName.Equals(glueName) && x.Glue.isShow == true).ProjectTo <MixingInfoDto>(_configMapper).OrderByDescending(x => x.ID).ToListAsync());
 }
Ejemplo n.º 2
0
        public async Task <object> Summary(int building)
        {
            var item     = _repoBuilding.FindById(building);
            var lineList = await _repoBuilding.FindAll().Where(x => x.ParentID == item.ID).ToListAsync();

            var plannings = await _repoPlan.FindAll().Where(x => lineList.Select(x => x.ID).Contains(x.BuildingID)).ToListAsync();

            // Header
            var header = new List <object> {
                new
                {
                    field      = "GlueID",
                    headerText = "GlueID",
                    width      = 60,
                    textAlign  = "Center",
                    minWidth   = 10
                },
                new
                {
                    field      = "Supplier",
                    headerText = "Supplier",
                    width      = 60,
                    textAlign  = "Center",
                    minWidth   = 10
                },
                new
                {
                    field      = "Chemical",
                    headerText = "Chemical",
                    width      = 60,
                    textAlign  = "Center",
                    minWidth   = 10
                }
            };

            foreach (var line in lineList)
            {
                var itemHeader = new
                {
                    field      = line.Name,
                    headerText = line.Name,
                    width      = 20,
                    textAlign  = "Center",
                    minWidth   = 5
                };
                header.Add(itemHeader);
            }
            // end header

            // Data
            var data  = new List <object>();
            var data2 = new List <object>();
            var model = (from glue in _repoGlue.FindAll().ToList()
                         join bpfc in _repoBPFC.FindAll().ToList() on glue.BPFCEstablishID equals bpfc.ID
                         join plan in _repoPlan.FindAll().ToList() on bpfc.ID equals plan.BPFCEstablishID
                         join bui in lineList on plan.BuildingID equals bui.ID
                         select new SummaryDto
            {
                GlueID = glue.ID,
                BuildingID = bui.ID,
                GlueName = glue.Name,
                BuildingName = bui.Name,
                Comsumption = glue.Consumption,
                ModelNameID = bpfc.ModelNameID,
                WorkingHour = plan.WorkingHour,
                HourlyOutput = plan.HourlyOutput
            }).ToList();

            var glueList = await _repoGlue.FindAll()
                           .Include(x => x.GlueIngredients)
                           .ThenInclude(x => x.Ingredient)
                           .ThenInclude(x => x.Supplier)
                           .Include(x => x.MixingInfos)
                           .Where(x => plannings.Select(p => p.BPFCEstablishID).Contains(x.BPFCEstablishID))
                           .ToListAsync();

            var glueDistinct = glueList.DistinctBy(x => x.Name);

            foreach (var glue in glueDistinct)
            {
                var itemData = new Dictionary <string, object>();
                var supplier = glue.GlueIngredients.FirstOrDefault(x => x.Position.Equals("A")) == null ? "#N/A" : glue.GlueIngredients.FirstOrDefault(x => x.Position.Equals("A")).Ingredient.Supplier.Name;
                itemData.Add("GlueID", glue.ID);
                itemData.Add("Supplier", supplier);
                itemData.Add("Chemical", glue.Name);
                var listTotal         = new List <double>();
                var listStandardTotal = new List <double>();
                var listWorkingHour   = new List <double>();
                var listHourlyOuput   = new List <double>();

                foreach (var line in lineList.OrderBy(x => x.Name))
                {
                    var sdtCon = model.FirstOrDefault(x => x.GlueName == glue.Name && x.BuildingID == line.ID);
                    if (sdtCon != null)
                    {
                        itemData.Add(line.Name, sdtCon.Comsumption.ToDouble());
                        listTotal.Add(sdtCon.Comsumption.ToDouble());
                        listWorkingHour.Add(sdtCon.WorkingHour.ToDouble());
                        listHourlyOuput.Add(sdtCon.HourlyOutput.ToDouble());
                        var standard = sdtCon.Comsumption.ToDouble() * sdtCon.WorkingHour.ToDouble() * sdtCon.HourlyOutput.ToDouble();
                        listStandardTotal.Add(standard);
                    }
                    else
                    {
                        itemData.Add(line.Name, 0);
                    }
                }

                itemData.Add("Standard", Math.Round(listStandardTotal.Sum(), 2));
                var    mixingInfos = _repoMixingInfo.FindAll().Where(x => x.GlueID == glue.ID).ToList();
                double realTotal   = 0;
                foreach (var real in mixingInfos)
                {
                    realTotal += real.ChemicalA.ToDouble() + real.ChemicalB.ToDouble() + real.ChemicalC.ToDouble() + real.ChemicalD.ToDouble() + real.ChemicalE.ToDouble();
                }

                itemData.Add("Real", realTotal);
                itemData.Add("Count", glue.MixingInfos.Count());
                data.Add(itemData);
            }
            header.Add(new
            {
                field      = "TotalComsumption",
                headerText = "Total Consumption",
                width      = 60,
                textAlign  = "Center",
                minWidth   = 10
            });
            // End Data
            return(new { header, data });
        }
Ejemplo n.º 3
0
 public async Task <List <MixingInfoDto> > GetMixingInfoByGlueID(int glueID)
 {
     return(await _repoMixingInfor.FindAll().Include(x => x.Glue).Where(x => x.GlueID == glueID).ProjectTo <MixingInfoDto>(_configMapper).OrderBy(x => x.ID).ToListAsync());
 }