public async Task <List <ScrapEscalationLog> > GetScrapEscalation(
     ScrapEscalationResourceParameter parameter
     )
 {
     return(await _context.ScrapEscalationLog
            .Include(x => x.ScrapEscalation)
            .AsNoTracking()
            .Where(x => x.ShiftDate == parameter.Date && x.Shift == parameter.Shift)
            .Where(x => x.WorkCenter.ToLower().StartsWith("asby"))
            .ToListAsync()
            .ConfigureAwait(false));
 }
Exemple #2
0
        public async Task <IActionResult> Get([FromQuery] ScrapEscalationResourceParameter parameter)
        {
            try
            {
                var data = await _service.GetScrapEscalation(parameter).ConfigureAwait(false);

                return(Ok(data));
            }
            catch (Exception e)
            {
                return(BadRequest(e.Message));
            }
        }
Exemple #3
0
        public async Task <IActionResult> GetNotAcknowledge(
            [FromQuery] ScrapEscalationResourceParameter parameter
            )
        {
            try
            {
                var data = await _service
                           .GetNotAcknowledgeScrapEscalation(parameter)
                           .ConfigureAwait(false);

                var scrapCodes = data.Select(x => x.ScrapCode).ToList();
                var defects    = await _fmsb2Context.Defects
                                 .AsNoTracking()
                                 .Where(x => scrapCodes.Contains(x.DefectId))
                                 .Select(x => new { x.DefectId, x.DefectName })
                                 .ToListAsync()
                                 .ConfigureAwait(false);

                var result = data.Select(
                    x =>
                    new
                {
                    x.Id,
                    x.WorkCenter,
                    x.ScrapCode,
                    x.AlertLevel,
                    x.Qty,
                    Threshold = x.ScrapEscalation.Qty,
                    Scrap     = defects.FirstOrDefault(
                        s => s.DefectId == x.ScrapCode
                        )?.DefectName
                }
                    )
                             .ToList();

                return(Ok(result));
            }
            catch (Exception e)
            {
                return(BadRequest(e.Message));
            }
        }