Exemple #1
0
 public static List <WorkingTimeModel> GetNSCForChart(int lineId, string date)
 {
     try
     {
         var db    = new PMSEntities();
         var times = BLLShift.GetWorkingTimeOfLine(lineId);
         var tdns  = db.TheoDoiNgays.Where(x => !x.Chuyen.IsDeleted && !x.Cum.IsDeleted && x.Date == date && x.MaChuyen == lineId).ToList();
         if (times != null && times.Count > 0)
         {
             foreach (var item in times)
             {
                 var tang = tdns.Where(x => x.Time >= item.TimeStart && x.Time <= item.TimeEnd && x.CommandTypeId == (int)eCommandRecive.ProductIncrease && x.ProductOutputTypeId == (int)eProductOutputType.KCS).Sum(x => x.ThanhPham);
                 var giam = tdns.Where(x => x.Time >= item.TimeStart && x.Time <= item.TimeEnd && x.CommandTypeId == (int)eCommandRecive.ProductReduce && x.ProductOutputTypeId == (int)eProductOutputType.KCS).Sum(x => x.ThanhPham);
                 tang     = tang - giam;
                 item.KCS = tang > 0 ? tang : 0;
             }
             return(times);
         }
     }
     catch (Exception)
     {
     }
     return(null);
 }