using LeaRun.Application.Busines.NBManage; using LeaRun.Application.Code; using LeaRun.Application.Entity.NBManage; using LeaRun.Util; using LeaRun.Util.WebControl; using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Web; using System.Web.Mvc; namespace LeaRun.Application.Web.Areas.NBManage.Controllers { public class NBHistorySearchController : MvcControllerBase { NBHistoryBLL historyBLL = new NBHistoryBLL(); //历史记录查询 #region 视图功能 //[HttpGet] //[HandlerAuthorize(PermissionMode.Enforce)] public ActionResult Index() { return View(); } #endregion #region 获取数据 [HttpGet] public ActionResult GetRecordJson(Pagination pagination, string queryType, string queryValue, string userNo, string imei, string thisDate = "", string lastDate = "") { var json = "[]"; var watch = CommonHelper.TimerStart(); DataTable data = null; try { string where = " Where 1=1 "; if (!string.IsNullOrEmpty(queryType)) { switch (queryType) { case "1": if (!string.IsNullOrEmpty(queryValue)) { where += " And f.AreaId=" + queryValue; } break; case "2": if (!string.IsNullOrEmpty(queryValue)) { where += " And e.BldgId=" + queryValue; } break; case "3": if (!string.IsNullOrEmpty(queryValue)) { where += " And d.ApmtId=" + queryValue; } break; case "4": if (!string.IsNullOrEmpty(queryValue)) { where += " And c.RoomId=" + queryValue; } break; } } if (!string.IsNullOrEmpty(userNo)) { where += " and c.UserNo like '%" + userNo + "%'"; } if (!string.IsNullOrEmpty(imei)) { where += " and b.IMEI like '%" + imei + "% '"; } if (!string.IsNullOrEmpty(thisDate) && string.IsNullOrEmpty(lastDate)) { where += " and a.ReadingDT > '" + thisDate + "'"; } if (string.IsNullOrEmpty(thisDate) && !string.IsNullOrEmpty(lastDate)) { where += " and a.ReadingDT < '" + lastDate + "'"; } if (!string.IsNullOrEmpty(thisDate) && !string.IsNullOrEmpty(lastDate)) { where += " and a.ReadingDT between '" + thisDate + "' And '" + lastDate + "'"; } if (!OperatorProvider.Provider.Current().IsSystem) { where += " And f.CompanyId= '" + OperatorProvider.Provider.Current().CompanyId + "'"; } data = historyBLL.GetHistory(where, pagination); var JsonData = new { rows = data, total = pagination.total, page = pagination.page, records = pagination.records, costtime = CommonHelper.TimerEnd(watch) }; return Content(JsonData.ToJson()); } catch (Exception ex) { var JsonData = new { rows = data, total = pagination.total, page = pagination.page, records = pagination.records, costtime = CommonHelper.TimerEnd(watch) }; return Content(JsonData.ToJson()); } } /// /// 小区列表(主要是绑定下拉框) /// /// 节点Id /// 返回列表Json [HttpGet] public ActionResult GetAreaListJson() { var data = historyBLL.GetAreaList(); return Content(data.ToJson()); } [HttpGet] public ActionResult GetBldgListJson(string parentId) { var data = historyBLL.GetBldgByArea(parentId); return Content(data.ToJson()); } [HttpGet] public ActionResult GetApmtListJson(string parentId) { var data = historyBLL.GetApmtByBldg(parentId); return Content(data.ToJson()); } [HttpGet] public ActionResult GetRoomListJson(string parentId) { var data = historyBLL.GetUserByApmt(parentId); return Content(data.ToJson()); } [HttpGet] public ActionResult GetDeviceJson(string parentId) { var data = historyBLL.GetDeviceByRoom(parentId); return Content(data.ToJson()); } #endregion public ActionResult GetPlatformRecord(string queryType, string queryValue, string thisDate = "", string lastDate = "", string isButton = "") { var dataResult = historyBLL.GetPlatformRecord(queryType, queryValue, thisDate, lastDate, isButton); return Content(dataResult.ToJson()); } /// /// 从华为平台获取历史记录 /// /// public ActionResult Platform() { return View(); } /// /// 实时数据 /// /// public ActionResult RealTimeData() { return View(); } public ActionResult GetRealTimeData(Pagination pagination, string areaID) { var watch = CommonHelper.TimerStart(); DataTable data = historyBLL.GetRealTimeData(pagination, areaID); var JsonData = new { rows = data, total = pagination.total, page = pagination.page, records = pagination.records, costtime = CommonHelper.TimerEnd(watch) }; return Content(JsonData.ToJson()); } #region 2022-03-25 GetLastedDataBySql public ActionResult GetLastedDataBySql() { return View(); } public ActionResult GetRealTimeDataBySql(Pagination pagination, string areaID) { var watch = CommonHelper.TimerStart(); DataTable data = historyBLL.GetRealTimeDataBySql(pagination, areaID); var JsonData = new { rows = data, total = pagination.total, page = pagination.page, records = pagination.records, costtime = CommonHelper.TimerEnd(watch) }; return Content(JsonData.ToJson()); } #endregion public string GetNBMeterHisData(string meterAddr, string beginDate) { string dtResult = historyBLL.GetNBMeterHisData(meterAddr, beginDate); return dtResult; } /// /// 每只表 去最先的数据 /// /// public ActionResult GetLastedData() { return View(); } } }