コード例 #1
0
ファイル: yhTable.cs プロジェクト: zyuhua88/GDT-Api
        /// <summary>
        /// 查询近十天的隐患类型
        /// </summary>
        /// <returns></returns>
        public HttpResponseMessage todayTj(int verify, int head_id, int com_id, int b_id, int c_id, int us_id)
        {
            string where = "";
            if (verify == 0)
            {
                where = " and y_usid in (select us_id from user_detail where head_id=" + head_id + ") ";
            }
            else if (verify == 1)
            {
                where = " and  y_usid in (select us_id from user_detail where com_id=" + com_id + ") ";
            }
            else if (verify == 2)
            {
                where = " and  y_usid in (select us_id from user_detail where b_id=" + b_id + ") ";
            }
            else
            {
                where = " and y_usid=" + us_id + " ";
            }
            string sql = "select convert(varchar(10),getdate(), 120) as today, y_type from yhtable where convert(varchar(10),dateadd(s,y_createtime,'1970-01-01'),120)=CONVERT(varchar(10),getdate(),120) " + where + ";" +
                         "select convert(varchar(10),dateadd(day, -1, getdate()), 120) as today, y_type from yhtable where convert(varchar(10), dateadd(s, y_createtime, '1970-01-01'), 120) = convert(varchar(10), dateadd(day, -1, getdate()), 120) " + where + ";" +
                         "select convert(varchar(10),dateadd(day, -2, getdate()), 120) as today, y_type from yhtable where convert(varchar(10), dateadd(s, y_createtime, '1970-01-01'), 120) = convert(varchar(10), dateadd(day, -2, getdate()), 120) " + where + ";" +
                         "select convert(varchar(10),dateadd(day, -3, getdate()), 120) as today, y_type from yhtable where convert(varchar(10), dateadd(s, y_createtime, '1970-01-01'), 120) = convert(varchar(10), dateadd(day, -3, getdate()), 120) " + where + ";" +
                         "select convert(varchar(10),dateadd(day, -4, getdate()), 120) as today, y_type from yhtable where convert(varchar(10), dateadd(s, y_createtime, '1970-01-01'), 120) = convert(varchar(10), dateadd(day, -4, getdate()), 120) " + where + ";" +
                         "select convert(varchar(10),dateadd(day, -5, getdate()), 120) as today, y_type from yhtable where convert(varchar(10), dateadd(s, y_createtime, '1970-01-01'), 120) = convert(varchar(10), dateadd(day, -5, getdate()), 120) " + where + ";" +
                         "select convert(varchar(10),dateadd(day, -6, getdate()), 120) as today, y_type from yhtable where convert(varchar(10), dateadd(s, y_createtime, '1970-01-01'), 120) = convert(varchar(10), dateadd(day, -6, getdate()), 120) " + where + ";" +
                         "select convert(varchar(10),dateadd(day, -7, getdate()), 120) as today, y_type from yhtable where convert(varchar(10), dateadd(s, y_createtime, '1970-01-01'), 120) = convert(varchar(10), dateadd(day, -7, getdate()), 120) " + where + ";" +
                         "select convert(varchar(10),dateadd(day, -8, getdate()), 120) as today, y_type from yhtable where convert(varchar(10), dateadd(s, y_createtime, '1970-01-01'), 120) = convert(varchar(10), dateadd(day, -8, getdate()), 120) " + where + ";" +
                         "select convert(varchar(10),dateadd(day, -9, getdate()), 120) as today, y_type from yhtable where convert(varchar(10), dateadd(s, y_createtime, '1970-01-01'), 120) = convert(varchar(10), dateadd(day, -9, getdate()), 120) " + where + "; ";
            DataSet ds = help.ToDataSet(sql);

            obj = new {
                code    = 0,
                today   = ConvertToEntity <Yh_SetData> .Convert(ds.Tables[0]),
                today_1 = ConvertToEntity <Yh_SetData> .Convert(ds.Tables[1]),
                today_2 = ConvertToEntity <Yh_SetData> .Convert(ds.Tables[2]),
                today_3 = ConvertToEntity <Yh_SetData> .Convert(ds.Tables[3]),
                today_4 = ConvertToEntity <Yh_SetData> .Convert(ds.Tables[4]),
                today_5 = ConvertToEntity <Yh_SetData> .Convert(ds.Tables[5]),
                today_6 = ConvertToEntity <Yh_SetData> .Convert(ds.Tables[6]),
                today_7 = ConvertToEntity <Yh_SetData> .Convert(ds.Tables[7]),
                today_8 = ConvertToEntity <Yh_SetData> .Convert(ds.Tables[8]),
                today_9 = ConvertToEntity <Yh_SetData> .Convert(ds.Tables[9])
            };
            return(Zh.Tool.Json.GetJson(obj));
        }