示例#1
0
        void GetChatData()
        {
            string type   = request["type"];
            string itemid = request["itemid"];

            BLL.dt_dimensioninfo bll = new BLL.dt_dimensioninfo();
            //TODO
            var data = bll.GetModelList($"a.updatetime>='2017-08-12 22:00:00' and a.updatetime <'2017-08-13 00:00:00' and a.dimension={type} and b.item_id = '{itemid}'");

            data     = data.Where(p => p.Second > 40).ToList();
            this.res = DTcms.Common.JsonHelper2.GetCommonObj(0, data);
        }
示例#2
0
        public void getJsonImgData(HttpContext context, int id, string Date)
        {
            BLL.dt_dimensioninfo bll = new BLL.dt_dimensioninfo();

            if (string.IsNullOrEmpty(Date))
            {
                Date = DateTime.Now.ToString("yyyy-MM-dd");
            }

            DateTime dt;
            string   sr = Date + " 00:00:00";

            if (!Utils.IsDate(sr, out dt))
            {
                Date = DateTime.Now.ToString("yyyy-MM-dd");
                dt   = DateTime.Parse(Date + " 00:00:00");
            }
            var q = bll.GetList($"hid={id} and updatetime between '" + dt.ToString("yyyy-MM-dd 00:00:00") + "' and '" + dt.ToString("yyyy-MM-dd 23:59:59") + "') ");

            context.Response.Write(JsonHelper.ObjectToJSON(q));
        }
示例#3
0
 public HttpResponseMessage GetMutiReport([FromBody] Model.ReportParam param)
 {
     if (!param.item_id.HasValue)
     {
         resObj = new Model.BaseResponse(1, "无效设备");
     }
     if (!param.dim_id.HasValue)
     {
         resObj = new Model.BaseResponse(1, "未知维度");
     }
     if (resObj.error == 0)
     {
         string where = " 1=1 ";
         if (!param.starttime.HasValue || !param.endtime.HasValue)
         {
             where += " and a.updatetime >= '" + DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss") + "' ";
         }
         else
         {
             where += " and a.updatetime >= '" + param.starttime.Value.ToString("yyyy-MM-dd HH:mm:ss") + "' and a.updatetime <= '" + param.endtime.Value.ToString("yyyy-MM-dd HH:mm:ss") + "'";
         }
         if (!string.IsNullOrEmpty(param.hid))
         {
             var h = new BLL.dt_historydata().GetModel(new Guid(param.hid));
             if (h != null)
             {
                 where += " and a.updatetime >= '" + h.updatetime.Value.AddHours(-12).ToString("yyyy-MM-dd HH:mm:ss") + "' and a.updatetime <= '" + h.updatetime.Value.AddHours(12).ToString("yyyy-MM-dd HH:mm:ss") + "'";
             }
             new BLL.dt_msg().SetReaded(param.msgid);
         }
         BLL.dt_dimensioninfo bll = new BLL.dt_dimensioninfo();
         var    data     = bll.GetModelList($"{where} and a.dimension={param.dim_id} and b.item_id = '{param.item_id}'");
         string newwhere = " 1=1 ";
         if (param.endtime.HasValue)
         {
             newwhere += " and a.updatetime >= '" + param.endtime.Value.AddHours(-1).ToString("yyyy-MM-dd HH:mm:ss") + "' and a.updatetime <= '" + param.endtime.Value.ToString("yyyy-MM-dd HH:mm:ss") + "'";
         }
         var data2 = bll.GetModelList($"{newwhere} and a.dimension={param.dim_id} and b.item_id = '{param.item_id}'");
         if (data.Count == 0)
         {
             resObj = new Model.BaseResponse(1, "无数据");
         }
         else
         {
             var ex = from p in data
                      group p by p.updatetime.ToString("yyyy-MM-dd") into g
                      select new Model.ReportData
             {
                 time  = Convert.ToDateTime(g.Key),
                 value = g.Max(p => p.value)
             };
             var ex2 = from p in data
                       group p by p.updatetime.ToString("yyyy-MM-dd HH:00:00") into g
                       select new Model.ReportData
             {
                 time  = Convert.ToDateTime(g.Key),
                 value = g.Max(p => p.value)
             };
             var ex3 = from p in data2
                       group p by p.updatetime.ToString("yyyy-MM-dd HH:mm:00") into g
                       select new Model.ReportData
             {
                 time  = Convert.ToDateTime(g.Key),
                 value = g.Max(p => p.value)
             };
             var ex4 = from p in data2.Where(c => c.updatetime >= data2.Max(d => d.updatetime).AddMinutes(-20))
                       group p by p.updatetime.ToString("yyyy-MM-dd HH:mm:00") into g
                       select new Model.ReportData
             {
                 time  = Convert.ToDateTime(g.Key),
                 value = g.Max(p => p.value)
             };
             resObj.data = new { MessageCount = new BLL.dt_msg().GetUnRecordCount(CurrentUser.USERID), ReportData_DD = ex.OrderBy(p => p.time).ToList(), ReportData_HH = ex2.OrderBy(p => p.time).ToList(), ReportData_mm = ex3.OrderBy(p => p.time).ToList(), ReportData_mm2 = ex4.OrderBy(p => p.time).ToList() };
         }
     }
     return(Json(resObj));
 }
示例#4
0
        public HttpResponseMessage GetReport([FromBody] Model.ReportParam param)
        {
            if (!param.item_id.HasValue)
            {
                resObj = new Model.BaseResponse(1, "无效设备");
            }
            if (!param.dim_id.HasValue)
            {
                resObj = new Model.BaseResponse(1, "未知维度");
            }
            if (resObj.error == 0)
            {
                string where = " 1=1 ";
                if (!param.starttime.HasValue || !param.endtime.HasValue)
                {
                    where += " and a.updatetime >= '" + DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss") + "' ";
                }
                else
                {
                    where += " and a.updatetime >= '" + param.starttime.Value.ToString("yyyy-MM-dd HH:mm:ss") + "' and a.updatetime <= '" + param.endtime.Value.ToString("yyyy-MM-dd HH:mm:ss") + "'";
                }
                if (!string.IsNullOrEmpty(param.hid))
                {
                    var h = new BLL.dt_historydata().GetModel(new Guid(param.hid));
                    if (h != null)
                    {
                        where += " and a.updatetime >= '" + h.updatetime.Value.AddHours(-12).ToString("yyyy-MM-dd HH:mm:ss") + "' and a.updatetime <= '" + h.updatetime.Value.AddHours(12).ToString("yyyy-MM-dd HH:mm:ss") + "'";
                    }
                    new BLL.dt_msg().SetReaded(param.msgid);
                }
                BLL.dt_dimensioninfo bll = new BLL.dt_dimensioninfo();
                var data = bll.GetModelList($"{where} and a.dimension={param.dim_id} and b.item_id = '{param.item_id}'");
                if (data.Count == 0)
                {
                    resObj = new Model.BaseResponse(1, "无数据");
                }
                else
                {
                    // DD
                    string format = "yyyy-MM-dd";
                    switch (param.Acc)
                    {
                    case "DD":
                        format = "yyyy-MM-dd";
                        break;

                    case "HH":
                        format = "yyyy-MM-dd HH:00:00";
                        break;

                    case "mm":
                        format = "yyyy-MM-dd HH:mm:00";
                        break;

                    default:
                        break;
                    }
                    var ex = from p in data
                             group p by p.updatetime.ToString(format) into g
                             select new Model.ReportData
                    {
                        time  = Convert.ToDateTime(g.Key),
                        value = g.Max(p => p.value)
                    };
                    resObj.data = new { MessageCount = new BLL.dt_msg().GetUnRecordCount(CurrentUser.USERID), ReportData = ex.OrderBy(p => p.time).ToList() };
                }
            }
            return(Json(resObj));
        }