コード例 #1
0
        private ReqRpt018DataBase GetEntityByDayRange(string EqpID, DateTime firstDay, DateTime lastDay)
        {
            ReqRpt018DataBase entity = new ReqRpt018DataBase();

            using (RPTContext db = new RPTContext())
            {
                var    list   = db.EQP_UPm_018.Where(w => w.EqpID == EqpID && DbFunctions.TruncateTime(w.Date) >= firstDay && DbFunctions.TruncateTime(w.Date) <= lastDay).ToList();
                double pr     = list.Sum(s => s.PRDMin);
                double ns     = list.Sum(s => s.NSTMin);
                double sb     = list.Sum(s => s.SBYMin);
                double sd     = list.Sum(s => s.SDTMin);
                double ud     = list.Sum(s => s.UDTMin);
                double en     = list.Sum(s => s.ENGMin);
                double ot     = pr + sb + sd + ud + en;
                double ut     = pr + sb;
                double pdtest = list.Sum(s => s.PRDTestMin);
                double pm     = list.Sum(s => s.PMMin);
                if (ot + ns > 0)
                {
                    entity.UPm         = ot == 0 ? 0 : (pr + sb) / ot;
                    entity.UUm         = ut == 0 ? 0 : pr / ut;
                    entity.SD          = ot == 0 ? 0 : sd / ot;
                    entity.UD          = ot == 0 ? 0 : ud / ot;
                    entity.PRDHour     = pr / 60;
                    entity.SBYHour     = sb / 60;
                    entity.SDTHour     = sd / 60;
                    entity.UDTHour     = ud / 60;
                    entity.NSTHour     = ns / 60;
                    entity.ENGHour     = en / 60;
                    entity.PRDTestHour = pdtest / 60;
                    entity.PMHour      = pm / 60;
                }
                return(entity);
            }
        }
コード例 #2
0
 private void GetEntitiesByType()
 {
     if (Type == "date" || (Type == "frame" && Frame == "date"))
     {
         foreach (string id in EqpIDs)
         {
             ReqRpt018TableEntity entity = new ReqRpt018TableEntity();
             entity.EqpID = id;
             foreach (string date in Dates)
             {
                 DateTime          dt   = DateTime.ParseExact(date, "yyyyMMdd", System.Globalization.CultureInfo.CurrentCulture);
                 ReqRpt018DataBase data = GetEntityByDayRange(id, dt, dt);
                 data.Date = date;
                 entity.Datas.Add(data);
             }
             entities.Add(entity);
         }
     }
     if (Type == "week" || (Type == "frame" && Frame == "week"))
     {
         foreach (string id in EqpIDs)
         {
             ReqRpt018TableEntity entity = new ReqRpt018TableEntity();
             entity.EqpID = id;
             foreach (string date in Dates)
             {
                 int year = Convert.ToInt16(date.Substring(0, 4));
                 int week = Convert.ToInt16(date.Substring(6));
                 Tuple <DateTime, DateTime> dts = GetFirstEndDayOfWeek(year, week, System.Globalization.CultureInfo.GetCultureInfo("zh-cn"));
                 DateTime          sdt          = dts.Item1;
                 DateTime          edt          = dts.Item2;
                 ReqRpt018DataBase data         = GetEntityByDayRange(id, sdt, edt);
                 data.Date = date;
                 entity.Datas.Add(data);
             }
             entities.Add(entity);
         }
     }
     if (Type == "month" || (Type == "frame" && Frame == "month"))
     {
         foreach (string id in EqpIDs)
         {
             ReqRpt018TableEntity entity = new ReqRpt018TableEntity();
             entity.EqpID = id;
             foreach (string date in Dates)
             {
                 DateTime          sdt  = Convert.ToDateTime(date.Replace('-', '/') + "/01");
                 DateTime          edt  = sdt.AddMonths(1).AddDays(-1);
                 ReqRpt018DataBase data = GetEntityByDayRange(id, sdt, edt);
                 data.Date = date;
                 entity.Datas.Add(data);
             }
             entities.Add(entity);
         }
     }
 }