#endregion /// <summary> /// 根据条件获取集合 /// </summary> /// <param name="id">key</param> /// <returns>实体</returns> public IEnumerable<models.Model.ScanNubProduct> QueryDateSingle(string datestr) { if (datestr=="oneday") { string date = DateTime.Now.AddDays(-1).ToString("yyyyMMdd"); //昨天时间 const string sql = "SELECT * FROM report_daily_newzsnumtotal_copy WHERE 日期 =@日期" + " and 规格 not like '36%'" + " and 规格 not like '21%'"; using (MySqlConnection connection = new MySqlConnection(connstr)) { connection.Open(); return connection.Query<models.Model.ScanNubProduct>(sql, new { 日期 = date }); } } else if(datestr=="week") { string lastday = DateTime.Now.AddDays(-1).ToString("yyyyMMdd"); string weeksday = DateTime.Now.AddDays(-8).ToString("yyyyMMdd"); // const string sql = "SELECT * FROM report_daily_newzsnumtotal_copy WHERE 日期 between '20180827' and '20180830'"; // string where = "WHERE 日期 between "+ weeksday + " and "+ lastday+ " and 规格 not like 32 and 规格 not like 36 and 规格 not like 21"; string where = "WHERE 日期 between " + weeksday + " and " + lastday + " and 规格 not like '36%'" + " and 规格 not like '21%'"; //过滤规格为36 和21开头的数据 return QueryList(where); } else { return null; } }