using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using LeaRun.Application.Entity.SecondaryWaterSupply; using LeaRun.Util.Extension; using LeaRun.Util.WebControl; using LeaRun.Util; using LeaRun.Application.Busines.SecondaryWaterSupply; using System.Collections; using System.Text; namespace LeaRun.Application.Web.Areas.SecondaryWaterSupply.Controllers { public class DeviceController : MvcControllerBase { DeviceBLL deviceBll = new DeviceBLL(); /// /// 设备总览 /// /// public ActionResult Index() { return View(); } /// /// 实施数据 /// /// public ActionResult RealtimeDevice() { return View(); } /// /// 设备列表 /// /// public ActionResult DeviceList() { return View(); } /// /// 添加设备 /// /// public ActionResult DeviceForm() { return View(); } /// /// 百度地图 /// /// public ActionResult BaiduMap() { return View(); } /// /// 获取设备列表 /// /// 分页信息 /// 查询关键词 /// public ActionResult GetDeviceList(Pagination pagination, string keyWord) { IEnumerable list = deviceBll.GetDeviceList(pagination,keyWord); var watch = CommonHelper.TimerStart(); var JsonData = new { rows = list, total = pagination.total, page = pagination.page, records = pagination.records, costtime = CommonHelper.TimerEnd(watch) }; return Content(JsonData.ToJson()); } /// /// 保存表具类型表单(新增、修改) /// /// 主键值 /// 表具类型实体 /// [HttpPost] [ValidateAntiForgeryToken] [AjaxOnly] public ActionResult SaveDevice(string keyValue, string strDevice) { DeviceEntity deviceEntiey = strDevice.ToObject(); //新增 if (string.IsNullOrEmpty(keyValue)) { if (deviceBll.SaveDevice(deviceEntiey)) { return Success("保存成功。"); } return Error("保存失败。"); } //更新 if (deviceBll.UpdateDevice(deviceEntiey)) { return Success("保存成功。"); } return Error("保存失败。"); } /// /// 获取表设备信息 /// /// /// public ActionResult GetDeviceById(string deviceId) { var device = deviceBll.GetDeviceById(deviceId); if (device == null) { return Content("[]"); } return Content(device.ToJson()); } /// /// 删除设备信息 /// /// /// public ActionResult DelteDevice(string deviceId) { if (deviceBll.DeleteDevice(deviceId)) { return Content("success"); } return Content("false"); } /// /// 设备列表 /// /// 复选框 /// 复选框状态 /// public ActionResult GetDeviceTree(bool showcheck = false, int checkstate = 0) { var meters = deviceBll.GetAllDevice(); var treeList = new List(); foreach (var item in meters) { var tree = new TreeEntity(); tree.id = item.SecondaryWaterSupplyId.ToString(); tree.text = item.PumpHouseName; tree.isexpand = true; tree.complete = true; tree.hasChildren = false; tree.parentId = "0"; tree.value = item.SecondaryWaterSupplyId.ToString(); tree.showcheck = showcheck; tree.checkstate = checkstate; tree.img = "fa fa-institution"; treeList.Add(tree); } return Content(LeaRun.Util.Json.ToJson(treeList)); } /// /// 获取所有设备最新信息 /// /// public string GetAllDeviceData() { IEnumerable deviceData = deviceBll.GetAllDeviceData(); StringBuilder sbHtml = new StringBuilder(); if (deviceData != null) { foreach (var item in deviceData) { sbHtml.Append("
"); sbHtml.Append("
"); sbHtml.Append("
"); sbHtml.Append(item.PumpHouseName); sbHtml.Append("
"); sbHtml.Append("
"); sbHtml.Append("
"); sbHtml.Append("进水压力:"); sbHtml.Append(""); sbHtml.Append("
"); sbHtml.Append("
"); sbHtml.Append("出水压力:"); sbHtml.Append(""); sbHtml.Append("
"); sbHtml.Append("
"); sbHtml.Append("更新时间:"); sbHtml.Append(""); sbHtml.Append("
"); sbHtml.Append("
"); sbHtml.Append("
"); sbHtml.Append("
"); } } return sbHtml.ToString(); } public ActionResult GetAllDeviceRealTimeData(string ids, Pagination pagination) { IEnumerable deviceData = deviceBll.GetAllDeviceRealTimeData(ids,pagination); return Content(LeaRun.Util.Json.ToJson(deviceData)); } } }