using MESClassLibrary.BLL.Log; using MESClassLibrary.EFModel; using System; using System.Collections.Generic; using System.Linq; using System.Reflection; using System.Text; using System.Threading.Tasks; namespace MESClassLibrary.BLL.Show { public class AnalysisBLL { BBMPTEntities dbe = new BBMPTEntities(); BasicBLL db = new BasicBLL(); public List SearchInfo(string ProductName) { List list = new List(); try { DateTime date = DateTime.Now; //DateTime date = Convert.ToDateTime("2019-07-08 10:00:00"); string nowTime = date.ToString("yyyy-MM-dd"); DateTime startTime = Convert.ToDateTime(nowTime + " 08:00:00");//班次开始时间 DateTime endTime = Convert.ToDateTime(nowTime + " 19:59:59");//班次结束时间 var info = dbe.tb_InspectResult.Where(p => p.productInfo.Contains(ProductName)); if (DateTime.Compare(date, startTime) < 0) { //昨天夜班 list = info.Where(p => p.createTime > endTime.AddDays(-1) && p.createTime < startTime).ToList(); } if (DateTime.Compare(date, endTime) > 0) { //今天夜班 list = info.Where(p => p.createTime > endTime && p.createTime <= date).ToList(); } if (DateTime.Compare(date, startTime) >= 0 && DateTime.Compare(date, endTime) <= 0) { //今天白班 list = info.Where(p => p.createTime >= startTime && p.createTime <= endTime).ToList(); } return list; } catch (Exception ex) { LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod()); return list; } } } }