NBHistorySearchController.cs 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. using LeaRun.Application.Busines.NBManage;
  2. using LeaRun.Application.Code;
  3. using LeaRun.Application.Entity.NBManage;
  4. using LeaRun.Util;
  5. using LeaRun.Util.WebControl;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Data;
  9. using System.Linq;
  10. using System.Web;
  11. using System.Web.Mvc;
  12. namespace LeaRun.Application.Web.Areas.NBManage.Controllers
  13. {
  14. public class NBHistorySearchController : MvcControllerBase
  15. {
  16. NBHistoryBLL historyBLL = new NBHistoryBLL();
  17. //历史记录查询
  18. #region 视图功能
  19. //[HttpGet]
  20. //[HandlerAuthorize(PermissionMode.Enforce)]
  21. public ActionResult Index()
  22. {
  23. return View();
  24. }
  25. #endregion
  26. #region 获取数据
  27. [HttpGet]
  28. public ActionResult GetRecordJson(Pagination pagination, string queryType, string queryValue, string userNo, string imei, string thisDate = "", string lastDate = "")
  29. {
  30. var json = "[]";
  31. var watch = CommonHelper.TimerStart();
  32. DataTable data = null;
  33. try
  34. {
  35. string where = " Where 1=1 ";
  36. if (!string.IsNullOrEmpty(queryType))
  37. {
  38. switch (queryType)
  39. {
  40. case "1":
  41. if (!string.IsNullOrEmpty(queryValue))
  42. {
  43. where += " And f.AreaId=" + queryValue;
  44. }
  45. break;
  46. case "2":
  47. if (!string.IsNullOrEmpty(queryValue))
  48. {
  49. where += " And e.BldgId=" + queryValue;
  50. }
  51. break;
  52. case "3":
  53. if (!string.IsNullOrEmpty(queryValue))
  54. {
  55. where += " And d.ApmtId=" + queryValue;
  56. }
  57. break;
  58. case "4":
  59. if (!string.IsNullOrEmpty(queryValue))
  60. {
  61. where += " And c.RoomId=" + queryValue;
  62. }
  63. break;
  64. }
  65. }
  66. if (!string.IsNullOrEmpty(userNo))
  67. {
  68. where += " and c.UserNo like '%" + userNo + "%'";
  69. }
  70. if (!string.IsNullOrEmpty(imei))
  71. {
  72. where += " and b.IMEI like '%" + imei + "% '";
  73. }
  74. if (!string.IsNullOrEmpty(thisDate) && string.IsNullOrEmpty(lastDate))
  75. {
  76. where += " and a.ReadingDT > '" + thisDate + "'";
  77. }
  78. if (string.IsNullOrEmpty(thisDate) && !string.IsNullOrEmpty(lastDate))
  79. {
  80. where += " and a.ReadingDT < '" + lastDate + "'";
  81. }
  82. if (!string.IsNullOrEmpty(thisDate) && !string.IsNullOrEmpty(lastDate))
  83. {
  84. where += " and a.ReadingDT between '" + thisDate + "' And '" + lastDate + "'";
  85. }
  86. if (!OperatorProvider.Provider.Current().IsSystem)
  87. {
  88. where += " And f.CompanyId= '" + OperatorProvider.Provider.Current().CompanyId + "'";
  89. }
  90. data = historyBLL.GetHistory(where, pagination);
  91. var JsonData = new
  92. {
  93. rows = data,
  94. total = pagination.total,
  95. page = pagination.page,
  96. records = pagination.records,
  97. costtime = CommonHelper.TimerEnd(watch)
  98. };
  99. return Content(JsonData.ToJson());
  100. }
  101. catch (Exception ex)
  102. {
  103. var JsonData = new
  104. {
  105. rows = data,
  106. total = pagination.total,
  107. page = pagination.page,
  108. records = pagination.records,
  109. costtime = CommonHelper.TimerEnd(watch)
  110. };
  111. return Content(JsonData.ToJson());
  112. }
  113. }
  114. /// <summary>
  115. /// 小区列表(主要是绑定下拉框)
  116. /// </summary>
  117. /// <param name="parentId">节点Id</param>
  118. /// <returns>返回列表Json</returns>
  119. [HttpGet]
  120. public ActionResult GetAreaListJson()
  121. {
  122. var data = historyBLL.GetAreaList();
  123. return Content(data.ToJson());
  124. }
  125. [HttpGet]
  126. public ActionResult GetBldgListJson(string parentId)
  127. {
  128. var data = historyBLL.GetBldgByArea(parentId);
  129. return Content(data.ToJson());
  130. }
  131. [HttpGet]
  132. public ActionResult GetApmtListJson(string parentId)
  133. {
  134. var data = historyBLL.GetApmtByBldg(parentId);
  135. return Content(data.ToJson());
  136. }
  137. [HttpGet]
  138. public ActionResult GetRoomListJson(string parentId)
  139. {
  140. var data = historyBLL.GetUserByApmt(parentId);
  141. return Content(data.ToJson());
  142. }
  143. [HttpGet]
  144. public ActionResult GetDeviceJson(string parentId)
  145. {
  146. var data = historyBLL.GetDeviceByRoom(parentId);
  147. return Content(data.ToJson());
  148. }
  149. #endregion
  150. public ActionResult GetPlatformRecord(string queryType, string queryValue, string thisDate = "", string lastDate = "", string isButton = "")
  151. {
  152. var dataResult = historyBLL.GetPlatformRecord(queryType, queryValue, thisDate, lastDate, isButton);
  153. return Content(dataResult.ToJson());
  154. }
  155. /// <summary>
  156. /// 从华为平台获取历史记录
  157. /// </summary>
  158. /// <returns></returns>
  159. public ActionResult Platform()
  160. {
  161. return View();
  162. }
  163. /// <summary>
  164. /// 实时数据
  165. /// </summary>
  166. /// <returns></returns>
  167. public ActionResult RealTimeData()
  168. {
  169. return View();
  170. }
  171. public ActionResult GetRealTimeData(Pagination pagination, string areaID)
  172. {
  173. var watch = CommonHelper.TimerStart();
  174. DataTable data = historyBLL.GetRealTimeData(pagination, areaID);
  175. var JsonData = new
  176. {
  177. rows = data,
  178. total = pagination.total,
  179. page = pagination.page,
  180. records = pagination.records,
  181. costtime = CommonHelper.TimerEnd(watch)
  182. };
  183. return Content(JsonData.ToJson());
  184. }
  185. #region 2022-03-25 GetLastedDataBySql
  186. public ActionResult GetLastedDataBySql()
  187. {
  188. return View();
  189. }
  190. public ActionResult GetRealTimeDataBySql(Pagination pagination, string areaID)
  191. {
  192. var watch = CommonHelper.TimerStart();
  193. DataTable data = historyBLL.GetRealTimeDataBySql(pagination, areaID);
  194. var JsonData = new
  195. {
  196. rows = data,
  197. total = pagination.total,
  198. page = pagination.page,
  199. records = pagination.records,
  200. costtime = CommonHelper.TimerEnd(watch)
  201. };
  202. return Content(JsonData.ToJson());
  203. }
  204. #endregion
  205. public string GetNBMeterHisData(string meterAddr, string beginDate)
  206. {
  207. string dtResult = historyBLL.GetNBMeterHisData(meterAddr, beginDate);
  208. return dtResult;
  209. }
  210. /// <summary>
  211. /// 每只表 去最先的数据
  212. /// </summary>
  213. /// <returns></returns>
  214. public ActionResult GetLastedData()
  215. {
  216. return View();
  217. }
  218. }
  219. }